Results 1 to 6 of 6
  1. #1
    pjtessi9 is offline Novice
    Windows 10 Office 365
    Join Date
    May 2019
    Posts
    12

    Post How to create a parameter query with multiple values

    Hi, I want to create a query that will prompted me with the choice of data to enter separated by a comma. (parameter prompt that accepts multiple values)

    Exemple: Prompt box opens, I type 11444,1443,14455 and then the query shows the results for these 3 inputs only... Sometimes I have to input 2 numbers, 4 numbers, etc...it's never the same amout.
    I want the values type to be separated by a comma.

    I tryied this examble below using the INSTR function but Access is saying that the syntax is not valid

    InStr([Enter number separated by commas],[Numbers])>"0"

    I am using Access 365



    Any ideas would be appreciated
    Thanks!

  2. #2
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,801
    I don't think that function makes sense for this. Perhaps your sql should use IN operator because of your cs values. However, I think you'll have to do this in code because each value would have to be delimited with single quotes, unless maybe you're willing to type those around every value you enter. If you try to do it in a stored query, you'll need a form that has a control containing the cs values, but again, everything needs to be delimited one way or the other - by your typing, or by code.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  3. #3
    Gicu's Avatar
    Gicu is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,115
    Can you show us the a screen shot of your data and of the query (in design view) where you try to implement this?

    Cheers,
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

  4. #4
    pjtessi9 is offline Novice
    Windows 10 Office 365
    Join Date
    May 2019
    Posts
    12
    Here is the screenshot requested...thanks for your help
    Click image for larger version. 

Name:	query.PNG 
Views:	19 
Size:	58.0 KB 
ID:	49281

  5. #5
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,801
    This has been asked and answered many times - there are even videos for it. Here's just one

    https://thedbguy.blogspot.com/2018/1...to-accept.html
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  6. #6
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,430
    There is one way if using IN in this sort of scenario - using the eval function

    Code:
    SELECT *
    FROM myTable
    WHERE Eval([myfield] & " IN (" & [enter values separated by comma] & ")")
    note the query view of this will add =true or <>false

    But as per the link provided by Micron, no validation although a space after a comma will still work (it wouldn't if using instr unless you also use the replace function to remove them)

    The other issue is if used to search for string values then the user needs to type for example, 'abc','def'

    As others have said, using parameters in this way is not a good way to go, better to use a form so the search criteria can be validated before being applied

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 4
    Last Post: 04-24-2020, 11:36 PM
  2. Replies: 2
    Last Post: 03-22-2020, 10:18 PM
  3. Replies: 1
    Last Post: 07-21-2015, 03:38 PM
  4. Parameter Query with several values
    By Zalina in forum Access
    Replies: 3
    Last Post: 12-15-2014, 07:18 AM
  5. Replies: 2
    Last Post: 11-19-2012, 05:42 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums