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

Query returns only certain results

Status
Not open for further replies.

Moss100

Technical User
Aug 10, 2004
586
GB
Hello I have a very simply query which returns results for currency amounts

The query is: Like LCase('*' & ([Type Search Criteria]) & '*')

If i type in 97.5 I get returned results, but if I type in 97.50 I do not get results.

The field tyupe is currency and there are records £97.50 in there.

Thanks Mark
 
LIKE compares character strings, not numbers. To do the comparison VB has to internally cast your currency value to a string and it drops the trailing zero. Hence 97.5 gets a match but 97.50 does not. You should probably use an equal(=) comparison operator rather than LIKE.

[blue]CurrencyField = [Type Search Criteria][/blue]
 
Will this still return results that are not exact - ie if i search for 97.50, I would like it to bring up results such as 197.50 etc... Thanks Mark
 
No. The equals operator (=) does an exact match. If the values are meaningful only to two places after the decimal then you can manually do the conversion of number to string and use LIKE. Something like this
Code:
Format(CurrencyField, "#.00") LIKE "*" & [Type Search Criteria] & "*"
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top