search from 2 or more columns

rupes_mahal

Registered User.
Local time
Today, 17:40
Joined
Aug 12, 2001
Messages
60
hi..

I have set up a search form. It is working fine. But I also have a problem with it.

I have a field called "Names" in the search form. At the moment, it is working fine, by looking at one column in the table and finding it. But i also have names in other columns. I want the search to be able to search from all the 4 columns from the table and then display the results.

The code for that part so far is:

If Not IsNothing(Me!names) Then
If IsNothing(gstrWhereCust) Then
gstrWhereCust = "[names1] Like " & Chr$(34) & Me!names
Else
gstrWhereCust = gstrWhereCust & " AND [names1] Like " & Chr$(34) & Me!names
End If
If Right$(Me!Names, 1) = "*" Then
gstrWhereCust = gstrWhereCust & Chr$(34)
Else
gstrWhereCust = gstrWhereCust & "*" & Chr$(34)
End If
End If


This works. As you can see it only looks at [names1] column and no other. How do i make it look at [names2], [names3], [names4], etc columns to do the search successfully. I need to add more code to it, but I dont know where and how to.

Please help..

Thank you in advance

ruby
 
You have your SQL string being created with AND. You need to create your SQL to say:

WHERE [names1] Like <criterion> OR WHERE [names2] Like <criterion> OR
etc.

HTH
 
hi..

How do i put the OR statement into the code i have pasted above. Please help.....i don't know VB/SQL that well.

I am going mad trying to work it out, but no joy so far...

PLEASE...ANYONE....IM DESPERATE

ruby
 

Users who are viewing this thread

Back
Top Bottom