Query Criteria passed through a text box

mikejaytlabustro

Access Database 2007 PH
Local time
Today, 15:05
Joined
Feb 11, 2013
Messages
93
I have a number_field in a query with a criteria passed through a text box.
Criteria: [Forms]![MyForm]![MyTextBox]
Textbox input: 18 or 19 or 20
I think access read it as a string and i dont have any idea how to do it right.
 
so what exactly is the problem? as described, your query should return any value where the user has entered 18,19 or 20 on myTextbox
 
if i put it directly to query criteria "18 or 19 or 20", i've got three results 18,19 and 20 which is what i am looking for. If i do it in textbox, i got no result.
 
ah - understand - you cannot use references to text boxes in that way i.e. use it to build a criteria in a query

To demonstrate, put '18 or 19 or 20' into your criteria and switch to sql view - you will see how the sql generated looks for multiple or's. Now change back to your query view and put in the reference to your textbox. Switch back to SQL view and you should be able to appreciate the problem.

instead you could use vba to generate a filter to apply to your form recordset or to modify the qryDef of your query
 

Users who are viewing this thread

Back
Top Bottom