J
jerseygirl54
I would like to be able to search classes by date. I have created a query
ClassesSearch Query and then created a form with an unbound combo box that
points to Row Source. When I click on the ... I have, ClassID [Classes],
ClassName [Classes], and Class Date [Classes] Sort Ascending.
I then created a button on the form and placed this code on the event:
Private Sub Command10_Click()
Dim strCriteria As String
If Not IsNull(Me.cboDateQuery) Then
'build criterion for search
strCriteria = "[Class Date] = """ & Me.[cboDateQuery] & """"
'open form filtered to selected class
DoCmd.OpenForm "Classes", WhereCondition:=strCriteria
'close dialogue form
DoCmd.Close acForm, Me.Name
Else
'otherwise inform user
MsgBox "Class date not valid.", vbInformation, "Invalid Operation"
End If
End Sub
First error - I get an error message on a valid date "The text you entered
isn't an item on the list. Select an item from the list, or enter text that
matches on of the listed items."
I select a class from the list then I get another error:
"Run-time error '3464': Data type mismatch in criteria expression." and it
points to the DoCmd.OpenForm "Classes"...line.
If someone could show me what I'm doing wrong, it would be greatly
appreciated!
ClassesSearch Query and then created a form with an unbound combo box that
points to Row Source. When I click on the ... I have, ClassID [Classes],
ClassName [Classes], and Class Date [Classes] Sort Ascending.
I then created a button on the form and placed this code on the event:
Private Sub Command10_Click()
Dim strCriteria As String
If Not IsNull(Me.cboDateQuery) Then
'build criterion for search
strCriteria = "[Class Date] = """ & Me.[cboDateQuery] & """"
'open form filtered to selected class
DoCmd.OpenForm "Classes", WhereCondition:=strCriteria
'close dialogue form
DoCmd.Close acForm, Me.Name
Else
'otherwise inform user
MsgBox "Class date not valid.", vbInformation, "Invalid Operation"
End If
End Sub
First error - I get an error message on a valid date "The text you entered
isn't an item on the list. Select an item from the list, or enter text that
matches on of the listed items."
I select a class from the list then I get another error:
"Run-time error '3464': Data type mismatch in criteria expression." and it
points to the DoCmd.OpenForm "Classes"...line.
If someone could show me what I'm doing wrong, it would be greatly
appreciated!