G
Guest
Hi, i have a search form set up with the following search textbox fields named:
keyword1
subject
and a combobox named:
topic
they are all related to "table 1" columns named [key words], [subjects],
[topic]
i want to make the text fields have the ability to search using any amount
of the word, and i want to make it so that they can fill out all or just one
of the search criteria. this is what i have so far.... and it keeps giving me
a syntax error.... and wont show the search results.... can someone tell me
where i went wrong with my coding?
thanks
Em~~
Private Sub cmdsearch_click()
Dim strwhere As String
Dim inglen As Long
If Not IsNull(Me.keyword1) Then
strwhere = strwhere & "([key words] = """ & Me.keyword1 & """) AND "
End If
If Not IsNull(Me.subject) Then
strwhere = strwhere & "([subjects] = """ & Me.subject & """) AND "
End If
If Not IsNull(Me.topic) Then
strwhere = strwhere & "([topics] = "" & Me.topic & "") AND "
End If
inglen = Len(strwhere) - 5
If inglen <= 0 Then
MsgBox "no criteria"
Else
strwhere = Left$(strwhere, inglen)
Me.filter = strwhere 'THIS IS WHERE IT KEEPS SENDING ME TO DEBUG...'
Me.FilterOn = True
End If
End Sub
keyword1
subject
and a combobox named:
topic
they are all related to "table 1" columns named [key words], [subjects],
[topic]
i want to make the text fields have the ability to search using any amount
of the word, and i want to make it so that they can fill out all or just one
of the search criteria. this is what i have so far.... and it keeps giving me
a syntax error.... and wont show the search results.... can someone tell me
where i went wrong with my coding?
thanks
Em~~
Private Sub cmdsearch_click()
Dim strwhere As String
Dim inglen As Long
If Not IsNull(Me.keyword1) Then
strwhere = strwhere & "([key words] = """ & Me.keyword1 & """) AND "
End If
If Not IsNull(Me.subject) Then
strwhere = strwhere & "([subjects] = """ & Me.subject & """) AND "
End If
If Not IsNull(Me.topic) Then
strwhere = strwhere & "([topics] = "" & Me.topic & "") AND "
End If
inglen = Len(strwhere) - 5
If inglen <= 0 Then
MsgBox "no criteria"
Else
strwhere = Left$(strwhere, inglen)
Me.filter = strwhere 'THIS IS WHERE IT KEEPS SENDING ME TO DEBUG...'
Me.FilterOn = True
End If
End Sub