Results 1 to 3 of 3
  1. #1
    Kshugerts003 is offline Novice
    Windows 10 Access 2016
    Join Date
    Oct 2019
    Posts
    1

    List number items in parameter prompt for a Query


    I am working with inventory of equipment and printing out tags for user requested Stock #'s. I created query that prompts the user for a stock #, which then in-turn generates a print preview of a label for that stock #. Is it possible to list stock #'s in the parameter prompt? Theoretically I would like the option of entering ranges and specific records. One possible input would be "4000362-4000364; 4000366". My goal is for the expected output for this input to be the following records 4000362, 4000363, 4000364, and 4000366. Any assistance would be greatly appreciated!

  2. #2
    Micron is online now Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,803
    Just about anything is possible if you can imagine it. However, to grab values like that would require a significant amount of code. The variation you're asking for makes it more complicated. If you had 2 textboxes for low to high values it would be easier to loop one by one from low to high. Putting it in one box means having to parse the values. If they're separated by dashes there's a range you'd have to loop through. If separated by commas they're individual values that have to be looped through. I think you'd be better off with a continuous or datasheet subform where the user inputs every value and you loop through the records. Alternatively, same type of form but 2 fields - 1 for the low value 1 for the high. If the high is null, it's a single value in the first field. Still, seems like a code solution, but then I'm somewhat biased in that regard!

    Maybe you will get other/better suggestions.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  3. #3
    Join Date
    Apr 2017
    Posts
    1,681
    As Micron did say, it is doable easily when you stick with single type of condition:
    Code:
    SELECT * FROM SomeTable WHERE SomeFied BETWEEN 3 AND 6;
    SELECT * FROM SomeTable WHERE SomeFied >= 3 AND SomeField <= 6;
    SELECT * FROM SomeTable WHERE SomeFied IN (3,4,5,6);
    SELECT * FROM SomeTable WHERE SomeFied IN (SELCT SomeField From SomeOtherTable WHERE SomeCondition = True);
    (Instead of values, you must have e.g. references to form controls, of course.)


    Having several different types of conditions may get really messy. Usually you need then to create a query string, and run it as command. And when creating the query string, you have to take into account all possible combinations of condition types (e.g.with 2 different condition types you'll have cases for having only 1st condition, having only 2nd condition, and having both conditions)

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

Similar Threads

  1. Replies: 2
    Last Post: 07-13-2019, 02:45 PM
  2. Replies: 3
    Last Post: 06-07-2019, 08:28 PM
  3. Replies: 15
    Last Post: 10-08-2015, 03:33 PM
  4. Replies: 14
    Last Post: 01-17-2013, 02:43 PM
  5. Query parameter prompt - Format message
    By daved292 in forum Queries
    Replies: 2
    Last Post: 06-08-2012, 11:09 AM

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