Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

search code in backend of Access form does not search!

Status
Not open for further replies.

accessdan

IS-IT--Management
Apr 3, 2002
10
AU
Hi everyone!

I've got the following code in part of my form:

If Not IsNull(Me("txtVal" & i)) Then
strWhere = strWhere & strJoinType & Application.BuildCriteria( _ "[" & Me("cbxFld" & i) & "]", _ fld.Type, Me("txtVal" & i) & "")
Else
strWhere = strWhere & strJoinType & "[" & Me("cbxFld" & i) & "] like '*'"
End If
End If
Next
'The final important SQL statement
strSQL = strSQL & " from [" & Me.lstTables & "] Where " & strWhere


At the moment, when I type in a search criteria in the txtVal0 box, then it searches for the exact match.
What I need to do is search for a match that is LIKE search criteria entered by the user (eg. find all records beginning with "abc" when "abc" is typed in the text box).

I've tried inserting a "LIKE" in the SQL statement but I think I may have something missing.



If anyone could help me with this, it'd be much appreciated...

Thanks,
Dan.
 
Here is an example of the proper usage of LIKE...

SELECT MyField1, MyField2
FROM MyTable
WHERE MyField2 Like "M*";

The above will display all records where Field2 contains any word that begins with "M".

Hope that helps.

Gary
gwinn7
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top