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 Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using "Like" when referencing a textbox control

Status
Not open for further replies.

Binnit

Technical User
Apr 28, 2004
627
US
On my form I have a an unbound text box which is used for searching on the first part of a postcode.

I need a query to reference the control using the "like" operator but cannot get this to work.

I have tried
Like [Forms]![frmReportSuite]![txtpcode] & "*"
and various other combinations but nothing seems to work.

Any suggestions welcomed

If IT ain’t working Binnit and Reboot
 
Its OK - got it now

Like "*" & [Forms]![frmReportSuite]![txtpcode] & "*"



If IT ain’t working Binnit and Reboot
 
Just for a bit of further information, the two statements you are using search two different ways.

The first statement you are using would search for the start of the string.

The second would search for any occurance of the string within the the field.

For example, say you have a table with a POSTCODE field and 2 values: DL3 6EE and TA3 6DL

We'll say that your textbox contains "DL" as your search criteria.

Your first query (Like [Forms]![frmReportSuite]![txtpcode] & "*")would return only the first row (DL3 6EE) as it starts with DL.

The second query (Like "*" & [Forms]![frmReportSuite]![txtpcode] & "*") would return both records as they both have a DL contained within the field.

As I say, just a bit of added information.

Hope this helps

HarleyQuinn
---------------------------------
Get the most out of Tek-Tips, read FAQ222-2244 before posting.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top