Pop Quiz: What's wrong with this code? When I compile and run it, it tells me "Object variable or With block variable not set, then it points at the ">>>>>"'s.
Private Sub cmdSearch_Click()
Dim strSQL As String
Dim strType As String
Dim strName As String
Dim strColor As String
strName = txtAName.Text
strType = lstType.Text
strColor = lstColor.Text
If strName = "" And strType = "" And strColor = "" Then
MsgBox "Please enter search criteria.", ... vbExclamation, "Search Results"
lstType.SetFocus
Else
strSQL = "SELECT Animal.type, Animal.name, ... Animal.color " & _
"FROM Animal " & _
"WHERE Animal.type = " & strType & _
" OR Animal.name = " & Trim(strName) & _
" OR Animal.color = " & Trim(strColor)
datAnimal.RecordSource = strSQL
datAnimal.Refresh
>>>>>>> If datAnimal.Recordset.EOF Then
MsgBox "There are no records that match your criteria.", vbExclamation, "Search Results"
End If
End If
End Sub
___________________________
I'm trying to write a form that I can search by either animal name, color, or type and have it display the results in a box next to it. I'm not sure what object to use for the box... I need help!!! =)
Private Sub cmdSearch_Click()
Dim strSQL As String
Dim strType As String
Dim strName As String
Dim strColor As String
strName = txtAName.Text
strType = lstType.Text
strColor = lstColor.Text
If strName = "" And strType = "" And strColor = "" Then
MsgBox "Please enter search criteria.", ... vbExclamation, "Search Results"
lstType.SetFocus
Else
strSQL = "SELECT Animal.type, Animal.name, ... Animal.color " & _
"FROM Animal " & _
"WHERE Animal.type = " & strType & _
" OR Animal.name = " & Trim(strName) & _
" OR Animal.color = " & Trim(strColor)
datAnimal.RecordSource = strSQL
datAnimal.Refresh
>>>>>>> If datAnimal.Recordset.EOF Then
MsgBox "There are no records that match your criteria.", vbExclamation, "Search Results"
End If
End If
End Sub
___________________________
I'm trying to write a form that I can search by either animal name, color, or type and have it display the results in a box next to it. I'm not sure what object to use for the box... I need help!!! =)