Text box values used in query contain brackets. (1 Viewer)

Rik_StHelens

Registered User.
Local time
Today, 11:32
Joined
Sep 15, 2009
Messages
164
Hi all,

I have a query which uses values in two hidden text boxes, in order to populate a sub form.

Unfortunately some times the data in the text box contains brackets within it as follows:

'120/60 ZR17 (55W)'

When this occurs the query returns no data, even though records with a matching code exists in the table I am working with where Speed is 'FR'.

Code:
WHERE (((stockdyn.SPEED)="FR") AND ((stockdyn.DESCRIPN) Like '*' & [forms]![frmSearch]![Text10] & '*'))

How can I get around this, as surely if I used quote marks it would take "[forms]![frmSearch]![Text10]" as the value I am searching for.

Thanks in advance,

Richard
 

GinaWhipp

AWF VIP
Local time
Today, 06:32
Joined
Jun 21, 2011
Messages
5,899
Let's try...

Code:
WHERE (((stockdyn.SPEED)="FR") AND ((stockdyn.DESCRIPN) Like ""*" & [forms]![frmSearch]![Text10] & "*""))
 

Rik_StHelens

Registered User.
Local time
Today, 11:32
Joined
Sep 15, 2009
Messages
164
I altered the code as you suggested.

Unfortunately the result is still the same:

If the query is searching for a matching record without brackets it returns it, but if the record contains brackets it fails to return a result.

I tested the theory by removing the brackets from the tyre sizes displayed alongside the bike model in the upper sub form (see attached images) which were not returning any values, and values were then returned as expected.

Unfortunately there are several thousand records containing brackets, and as the data file comes from a separate system which refreshes the file on a daily basis, altering the offending records isn't really an option.
 

Attachments

  • With Brackets Error.jpg
    With Brackets Error.jpg
    56.9 KB · Views: 79
  • Without Brackets No Error.jpg
    Without Brackets No Error.jpg
    92.3 KB · Views: 74

GinaWhipp

AWF VIP
Local time
Today, 06:32
Joined
Jun 21, 2011
Messages
5,899
I just tested this and it should work, so I'm wondering if something else is going on. Anyway you can upload a stripped down version of the database?
 

Users who are viewing this thread

Top Bottom