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

Query with parameters from a form text fiels

Status
Not open for further replies.

Rich47

Programmer
Mar 24, 2011
1
US
I have Make Table query where I want to add new records based on numbers in a Form text field.

In the criteria section of the query I have [forms]![MyForm]![Text1]

I want to be able to enter several numbers in the Form text field to add multiple records to the table. I have tried entering in the text field "2" or "4" or "6" running the query but no records are returned. If I just enter one number "2" it works fine so I'm guessing it can't interpret the "or" clause.

I have also tried in the criteria box of the query- In([Forms]![MyForm]![Text1]) and then listed a series of number in the test box e.g. 2,4,6 still works with only one number but not several.

I think I have triedjust about every possible combinations of quotes, commas, and & symbols, but no luck.
Any suggestions?
 
As you have found, this won't work. You might be able to use syntax like:
Code:
SELECT *
FROM [YourTableNameHere]
WHERE Instr("," & Forms!MyForm!Text1 & ",","," & [YourFieldNameHere] & "'")>0;
This assumes your text box has comma delimited values with no spaces.


Duane
Hook'D on Access
MS Access MVP
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top