Need help with code for Search Form (1 Viewer)

jdp103

Registered User.
Local time
Yesterday, 23:43
Joined
Sep 26, 2003
Messages
46
I have created a search form in my database. The form consists of a textbox and a button. I want the users to be able to enter a word in the textbox and click the button to search all the records in the database that have that word in a particular field. The problem that I am having is with the syntax. I have it set up as follows:

The button code will open a search results subform based on a query. If I use just the query and type in Like "*backup*" in the criteria I get my records, no problem. However, I can't figure out how to get this syntax correct in the code. Here is what I have now:

Dim filler As String
Dim cancel As Boolean
gettext = Nz(Me!Text34, "None")
filler = """"
gettext2 = "Like "
gettext3 = "*" & gettext & "*"
results = "SearchResultsSubForm"
StrFilter = "[ShortDesc] = "
srchcrit = StrFilter & filler & gettext2 & gettext3 & filler

If gettext = "None" Then
MsgBox "Please enter text to search for."
cancel = True
Else

DoCmd.OpenForm results, acNormal, , srchcrit, acFormEdit, acWindowNormal​

I have tried every possible combination and I just can't get it to work! Help please!!!

Thank you!
Jessica
 
Last edited:

Users who are viewing this thread

Top Bottom