request several data in a parameter (1 Viewer)

guihualinux

New member
Local time
Tomorrow, 00:47
Joined
Feb 14, 2022
Messages
8
Hi guys, I am trying to create a query that asks me for several data in a parameter.
For example, in my table I have 1, 2, 3, 4, 5 and 6 as data.
and I want a parameter that allows me to enter several data, to return me the numbers that I entered.
 

theDBguy

I’m here to help
Staff member
Local time
Today, 15:47
Joined
Oct 29, 2018
Messages
18,962
Hi. Sorry can't give you the link right now, but try visiting my blog site and do a search on multiple value parameter.

I'll follow up later...
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 18:47
Joined
Feb 19, 2002
Messages
36,284
When you have to use InStr() or LIke, that should give you a clue that the suggested method isn't working as you need it to work. What you are ending up with is:

Where something In("1,2,3") which is NOT the same as
Where something In(1,2,3)

So, Instr() and Like * will work but they will both force full table scans which can be slow for large recordsets.

I've attached an example of building the SQL in VBA. This is one of the few situations where I use embedded SQL. There are three samples of how you would use the method. Don't forget to enclose items in quotes when they are strings rather than numbers.
 

Attachments

  • FillFormFields_20210319.zip
    101.6 KB · Views: 176

Users who are viewing this thread

Top Bottom