Search Button - - - - Like Statement????

S

Strow

Below is my serach button, the problem I am ahaving is that the string
for but the name and/or phone number has to be exact?? is there some
sort of like statement ahere i can type in just part of a name and
phone and get multiple records??? thanks
John


Private Sub cmdSearch_Click()
Dim strSearch As String
Dim strReportName As String
Dim strCriteria As String
strSearch = ""

If Nz(Me.txtfNameSeach, "") <> "" Then
strSearch = "name = '" & Me.txtfNameSeach & "'"
End If
If Nz(Me.txtphoneSeach, "") <> "" Then
If strSearch <> "" Then
strSearch = strSearch & " AND "
End If
strSearch = strSearch & "Telephone = '" & Me.txtphoneSeach & "'"
End If

If strSearch <> "" Then
DoCmd.OpenForm "All", , , strSearch
DoEvents
If Forms!All.Recordset.EOF Then
MsgBox "No Records Found"
Forms!All.FilterOn = False
End If
Else

DoCmd.Close acForm, "Find"
End If
End Sub
 
S

SusanV

You need to include wildcards:

strSearch = "name Like '*" & Me.txtfNameSeach & "*'"
 

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

Similar Threads


Top