Solved How to select all entries that begin with a given value? (1 Viewer)

mamradzelvy

Member
Local time
Today, 09:10
Joined
Apr 14, 2020
Messages
145
Hi,
I'm using a simple query to export records based on client names.
And the WHERE part of my query looks like this WHERE (((Tabule1.TabKlient)=[Formuláře]![formTabuleMini]![txtKlient])) OR ((([Formuláře]![formTabuleMini]![txtKlient]) Is Null));
(This works well, "formuláře" is a valid syntax in my language's access version, don't worry about it)
What im worried about is how to make it so that the rest of the client name can be whatever, for instance i have clients such as "Pepsi; Pepsi-CityName; Pepsi-AnotherCity" and when i put in just pepsi, i would like it to select everything that begins with pepsi.
How would i write the proper syntax for that?
 

bob fitz

AWF VIP
Local time
Today, 08:10
Joined
May 23, 2011
Messages
4,719
Try:
WHERE (((Tabule1.TabKlient)=Like [Formuláře]![formTabuleMini]![txtKlient] & "*")) OR ((([Formuláře]![formTabuleMini]![txtKlient]) Is Null));
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 15:10
Joined
May 7, 2009
Messages
19,230
Code:
WHERE ((InStr([TabKlient],Nz([Formuláře]![formTabuleMini]![txtKlient],[TabKlient]))>0));
 

Isaac

Lifelong Learner
Local time
Today, 00:10
Joined
Mar 14, 2017
Messages
8,777
The Like will probably perform faster than the instr()
 

Users who are viewing this thread

Top Bottom