All,
I am trying to create a search form to have users search for data using 2 parameters. I have a user form with a list box, three text boxes & a find button.
1st text box is txt_sname (Combobox)
2nd text box is txt_sdate
3rd text box is txt_sdate1
list box is lst_main
What I am trying to do here is have the user select a name from the combo box drop down & enter dates for example 12/11/2015 - 01/01/2016. Then I want the query to display in the list box.
The table I have set up which is "Main" has the following fields:
t_Name
t_Date
t_ContactID
t_Score
t_Comments
The query will look at t_Date and and t_Name, if the data matches the parameters from the text boxes it will then display the info on the list box. Can anyone point me in the right direction?
I am using the following to pass data to the table:
Private Sub c_Submit_Click()
Dim db As Database
Dim rec As Recordset
Set db = CurrentDb
Set rec = db.OpenRecordset("Select * from Main")
If IsNull(Me.txt_Name.Value) Or IsNull(Me.txt_Date.Value) Or IsNull(Me.txt_Contact.Value) Then
MsgBox ("Error! Fill out all the fields!"), vbExclamation
Exit Sub
End If
rec.AddNew
rec("t_Name") = Me.txt_Name.Value
rec("t_Date") = Me.txt_Date
rec("t_ContactID") = Me.txt_Contact
rec("t_Score") = Me.txt_Score
rec("t_Comments") = Me.txt_Comments
rec.Update
Set rec = Nothing
Set db = Nothing
Me.txt_Name = Null
Me.txt_Date = Null
Me.txt_Contact = Null
Me.txt_Score = Null
Me.txt_Comments = Null
Me.Text32.Requery
MsgBox ("Record Added Successfully!")
End Sub
Thank you everyone for the help! Cheers!