search with wild cards

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,
I have a table of book titles with an index back to an author table. I
would like to have a form with a search (find) button on it where I can type
in a title or part of a title using wild cards and get a display of all the
books and authors that match my search pattern. Is this possible? I know I
can do a report with a restricton based on the complete title, but I don't
know about using wild cards. An example of code would be greatly appreciated.

Thanks,
Phil
 
Apparently you want to "get a display" in "can do a report". Assuming you
have a text box on your form "txtFindTitle". Your code to open the report
might look like:

Dim strWhere as String
strWhere = "1=1 "
If not IsNull(Me.txtFindTitle) Then
strWhere = strWhere " AND [BookTitle] Like """*" & _
Me.txtFindTitle & """*"
End If
DoCmd.OpenReport "rptYourRpt", acPreview, , strWhere
 
Back
Top