Use of a asterisk wildcard in code?

joe789

Registered User.
Local time
Today, 12:24
Joined
Mar 22, 2001
Messages
154
Hello Folks,

Part of a small search form I have has two text boxes, one for last name and one for first name, along with a command button to execute a code that search for any matches based on the last name or first name a user enters. The code works perfectly and if a user enters the first name and last name of a client another form will open to show those matches; otherwise, the form will show nothing indicating nothing is found. I have a small note on the form stating that if a wild card is to be used, the user must place a asterisk as the last character in the field of last name and/or first name, which also works well. I would like to try to make this code so that the user doesn't need to use an asterisk, but whenever I try to place the asterisk in the code, it just doesn't work. This is the code I have:

DoCmd.OpenForm "SEARCHRESULTS", , , "[LAST NAME OF CLIENT] like Forms!SEARCH!Text11 and [FIRST NAME OF CLIENT] like Forms!SEARCH!Text13"

So I would want something like this:DoCmd.OpenForm "SEARCHRESULTS", , , "[LAST NAME OF CLIENT] like Forms!SEARCH!Text11&"*"& and [FIRST NAME OF CLIENT] like Forms!SEARCH!Text13"&"*"& .... but I tried this and about a dozen other ways, and it just doesn't work ... I am guessing a syntax error of sorts?

How can I place an asterisk in the above code line successfully?

Any help would be greatly appreciate!!

Thank you,

Joe
 
Code:
DoCmd.OpenForm "SEARCHRESULTS", , , "[LAST NAME OF CLIENT] LIKE " & Chr(34) & Forms!Search!Text11 & "*" & Chr(34) & " AND " & _
                                    "[FIRST NAME OF CLIENT] LIKE " & Chr(34) & Forms!Search!Text13 & "*" & Chr(34)
 

Users who are viewing this thread

Back
Top Bottom