Results 1 to 3 of 3
  1. #1
    tagteam is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2013
    Posts
    486

    allow multiple values in unbound field for query parameters

    I am trying to find a way to allow the user to enter multiple numbers in an unbound box that I will pass to a query as parameters. I already have it set up to pas the parameters from the form but if i try to do more than one number it doesnt work.
    I have tried
    1306 or 1307 or 1308
    1306, 1307, 1308
    "1306 or 1307 or 1308"

    I was reading somewhere that when the value is picked up from the form it is not like you are typing it right in the criteria box of the query.

    So are there any other options here?
    Is there a way to enter all the number in a box and then use vba to create an array and then pass that to the query? I am intermediate with access but a beginner with vba.
    Thanks

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    It isn't the same as typing in the criteria in design view. Design view is just a user interface to create SQL. When you type that in the design grid, Access understands and converts it to proper SQL. "1306 or 1307 or 1308" would become SQL of:

    WHERE FieldName = 1306 or FieldName = 1307 or FieldName = 1308

    When you put that in a form control, Access doesn't make the conversion for you. I'm not sure of an easier way, so I suspect you're stuck with VBA to convert the input into proper SQL. The exact solution I would choose would likely depend on the end goal. If it's to open a form/report, I'd create a wherecondition rather than manipulating the query.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,525
    The BEST way I think, let the user enter values into a table (multiple values)...link the table to your query results.

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

Similar Threads

  1. Replies: 7
    Last Post: 04-28-2014, 07:09 AM
  2. Replies: 7
    Last Post: 08-30-2013, 03:43 PM
  3. Update Query selecting multiple values in one field
    By Zipster1967 in forum Queries
    Replies: 1
    Last Post: 08-15-2011, 12:22 PM
  4. query field with multiple values
    By mknowles in forum Queries
    Replies: 1
    Last Post: 11-24-2009, 11:31 AM
  5. Query multiple values in a field
    By JAYgarti in forum Access
    Replies: 0
    Last Post: 07-09-2009, 09:52 AM

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