Search Results

G

Guest

I have a form with a text box and a command button. When the user types in a
last name and uses the command button it shows the results in a subform. I
would also like the user to be able to put in a last name or a drivers
license number and the seach button would find it. What would I add to my
code to include searching for field DLNumber. Heres is the code I am using.
Ive tried just duplicating from If Len to Boland=true but I end up with no
results. Is this because I am searching for a number and not text if so how
could I do this. Thanks

Dim strFilter As String
Dim bolAnd As Boolean
bolAnd = False
strFilter = ""
If Len(Me.Text0.Value) > 0 Then
If bolAnd Then
strFilter = strFilter & " and "
End If
strFilter = strFilter & " LastName Like '*" & Me.Text0.Value & "*'"
bolAnd = True
End If

With Me.[MN_Person1].Form
If .Dirty Then
.Dirty = False
End If
If strFilter = "" Then
.FilterOn = False 'Nothing entered: show all records.
Else
.Filter = strFilter
.FilterOn = True
End If
End With
 
G

Guest

Thanks for the info. I just made a command button for each type of search I
wanted to do. Is it possible to have a command button to search for two
differant types of searches.
Example search the last name field or DL Number field with one text box and
one button and then show results in a subform.
When I try doing multiple searches I get no results.

Ofer said:
Check this link for a search form sample, it should give you a starting point

http://www.databasedev.co.uk/text_search.html

--
\\// Live Long and Prosper \\//
BS"D


lostandconfused said:
I have a form with a text box and a command button. When the user types in a
last name and uses the command button it shows the results in a subform. I
would also like the user to be able to put in a last name or a drivers
license number and the seach button would find it. What would I add to my
code to include searching for field DLNumber. Heres is the code I am using.
Ive tried just duplicating from If Len to Boland=true but I end up with no
results. Is this because I am searching for a number and not text if so how
could I do this. Thanks

Dim strFilter As String
Dim bolAnd As Boolean
bolAnd = False
strFilter = ""
If Len(Me.Text0.Value) > 0 Then
If bolAnd Then
strFilter = strFilter & " and "
End If
strFilter = strFilter & " LastName Like '*" & Me.Text0.Value & "*'"
bolAnd = True
End If

With Me.[MN_Person1].Form
If .Dirty Then
.Dirty = False
End If
If strFilter = "" Then
.FilterOn = False 'Nothing entered: show all records.
Else
.Filter = strFilter
.FilterOn = True
End If
End With
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top