How to open a report based on the text that I enter

X

xd

Currently I have a form use to provide information to open a report.
If i want to add one more text box, call details
how to write if the report open will find all the record in any fields
in the table which contains the words that type in the text box?

I do have one sample code is like this:

If Not IsNull(details) Then
strWhere = strWhere & " AND details= " & "'" & details & "'"
End If

But this kind of statement will just match the exact word have in the
details field in the table.
It can't do a searching job to search all the fields contain this
word.
How can I change this code?
 
K

Ken Sheridan

You could use the Like operator along with the * wildcard character to return
rows where the concatenated values of all relevant fields contain the
substring, e.g.

Dim strWhere As String

<code to build criteria on basis of other controls>

If Not IsNull(Me.[Details]) Then
strWhere = strWhere & _
" And [FirstName] & " & _
"[LastName] & " & _
"[Address] " & _
"Like ""*" & Me.[Details] & "*"""

DoCmd.OpenReport "YourReport", _
View:=acViewPreview, _
WhereCondition:=strWhere
End If

Ken Sheridan
Stafford, England
 
Top