Searching multiple columns for partial text (1 Viewer)

dkinnz

Registered User
Joined
Jan 8, 2007
Messages
29
Hi,

I've been searching through the forum and I've found a few helpful posts, but I'm still having trouble pulling everything together.
Here's the situation:
In a user form, a value is selected from a combo box. I then want a search to be done on a query to look for that value and filter down to all the records that contain that value. The issue is the value that what I'm looking for is located in any one of three known columns (out of about 50 columns total), and the value that is being searched for is only a partial text in the field.

For example...
I select the value "Monk" from the combo box. I then want to search three columns in the query for it but the fields containing "Monk" actually might be something like "Monk-123" or "Monk ABC".
In summary, I want to filter out all records that don't contain the partial-text "Monk" which is located in any one of those three columns.

Thank you a ton for ANY help you can give!
dkinnz
 

pbaldy

Wino Moderator
Staff member
Joined
Aug 30, 2003
Messages
33,669
Try

WHERE Field1 Like "*" & Forms!FormName.ComboName & "*" OR Field2 Like "*" & Forms!FormName.ComboName & "*" OR Field3 Like "*" & Forms!FormName.ComboName & "*"
 

dkinnz

Registered User
Joined
Jan 8, 2007
Messages
29
Cool. Thanks for the replies. It's exactly what I was looking for.
 

dkinnz

Registered User
Joined
Jan 8, 2007
Messages
29
So, I ran into a problem and I've been trying to find an answer to it in this forum. It's related to the parital text search problem that I'm having but with a twist. I try and search the forum the best I can before I post...

I created a combo box whose values aren't in a query table, but each combo box value corresponds to data that I want to search for in the query.
For Instance,
User selects "Alpha" from the combo box.
"Alpha" actually corresponds to the partial text values of "A123", "B123" and "C123" which are in the query table. So, if the user selects Alpha, what would the code be to search through the column(s) to look for any or all of those values?

I'm guessing it would look something like this...
Code:
If cboGroup.Value = "Alpha" Then

'The following is definitely wrong...so what would go here?
Set SearchValue = "A123" Or "B123" Or "C123"  

'ElseIf cboGroup.Value = "Beta" Then
'etc.

End If
Any help is extremely appreciated!
 

dkinnz

Registered User
Joined
Jan 8, 2007
Messages
29
Looking over my last post, I'm not sure if it's very clear what I'm trying to do. I guess I'm just trying to figure out how to define a variable that is equal to multiple values...?
PLEASE help if you can!

Cheers,
dkinnz
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Top Bottom