View Full Version : query parameter


Accessme2
06-17-2009, 11:07 AM
Hi everyone,
I have a question i have a form with two fields. I want to run a query using those fields as a parameter on my query.
one fields is status then other fields is product. the status can be 1 to 999
the product can be any product code and a combination of them. so when they enter those fields they can enter:
Status: 100
product: 500
so I want to query the status and product like *500* but when i run the query
I get anything that have a 5 and not the whole 500.. so i am getting 750, 550 etc.
what i have in:

SELECT trak_table.STATUS, trak_table.NAME, trak_table.CONTRACTOR, trak_table.FILENUM, trak_table.QUOTENUM, trak_table.ORDERNUM, blablablabla.......
HAVING (((trak_table.STATUS) Like "*" & [Forms]![TTSF]![STATUS_IN] & "*") AND ((trak_table.PRODUCTS) Like "*" & [forms]![TTSF]![PROCTS_IN] & "*"))
ORDER BY trak_table.NAME;

So waht i need is to be able to enter a string like 500 and get anything that have 500 not 1500 or 5000 only the 500 plus anything else like 500,600.. or 700,500,200 etc..

any help would be appreciated..

thanks
Jorge

Galaxiom
06-17-2009, 07:14 PM
You need code to the effect:

Like [Forms]![TTSF]![STATUS_IN] OR [Forms]![TTSF]![STATUS_IN] & ",*" OR "*," & [Forms]![TTSF]![STATUS_IN] & ",*"

Note: This syntax is in the criteria of Access design view.
The sql syntax will be [mytable].[myfield] Like blah OR [mytable].[myfield] Like blah-blah etc etc

Incidentally Like "[abc]*" is the same as Like "a*" or "b*" or "c*"