Results 1 to 7 of 7
  1. #1
    eskybel is offline Advanced Beginner
    Windows XP Access 2010 32bit
    Join Date
    May 2012
    Posts
    74

    Using Like to prompt input of multiple values

    Hello,



    I have a query that returns values and displays them in a report, in which the user will be prompted with a box to enter a value to use as criteria, such as if I want the report run for a specific sales rep, the criteria is like [Rep #?]. There is no field called Rep #?, so obviously it asks for input. What we typically do is either enter each number separately, or use * to pull everything.

    I would like to know how, if possible, a user could enter multiple values in the single input box.

    So for example, we have a rep that has two different rep numbers. I would like to populate the report with info based on his two rep numbers, so when the report prompts for [Rep #?], the user could enter something like "01 and 02."

    I've tried:
    01,02
    01, 02
    01 or 02

    Is that possible?

  2. #2
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,724
    You could adjust your design to correct this -- or did you intend for rep number to NOT be unique?

    we have a rep that has two different rep numbers.
    It does sound like a design issue.

    It would be helpful if you could post the actual SQL of the query involved.
    Is rep number a number or text/string?
    Perhaps 1 OR 2, but we need to see the SQL.

  3. #3
    eskybel is offline Advanced Beginner
    Windows XP Access 2010 32bit
    Join Date
    May 2012
    Posts
    74
    Quote Originally Posted by orange View Post
    You could adjust your design to correct this -- or did you intend for rep number to NOT be unique?

    It does sound like a design issue.

    It would be helpful if you could post the actual SQL of the query involved.
    Is rep number a number or text/string?
    Perhaps 1 OR 2, but we need to see the SQL.
    Rep number is a number.

    Because of some changes on the sales rep side, their name and some specific information to them changed. So, they were granted a new Rep # to go forward with so we could assign sales of parts to their new Rep #. But, there are also sales waiting to be finalized under their old number. So, right now, they have two numbers. We generate a sales report for each specific Rep, but now they have two numbers, so we either have to generate the report twice for them, or we find a way to combine them, based on user input. Eventually they won't have two numbers, but for the foreseeable, they do.

    I just used the Query Design button in Access, no manual code. But, I guess here's the piece that prompts the user...if it helps?
    WHERE (((xxxxx.GROUPID) Like [Rep #?])

  4. #4
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,724
    If you know that rep number 20 and 49 refer to the same person, - let me say if you know
    which numbers refer to the specific rep
    - then I'm sure this can be done.
    How many sales reps? Do you have a list of the Sales reps and their numbers? Do you have any 2 John Smiths etc?
    Are the First/LastName combos all unique?
    Need to create a table that has SalesRep and number, then some joining to get the proper data.

  5. #5
    eskybel is offline Advanced Beginner
    Windows XP Access 2010 32bit
    Join Date
    May 2012
    Posts
    74
    Ok, thank you for the update.

    We only have two reps, but 3 numbers, as an example. It's pretty simple I suppose. If there wasn't an easy, built in way to just type "01 or 06" in the first prompt, then it's likely not worth fixing the design to make it work. We can just have two reports. Thank you!

  6. #6
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,724
    I wouldn't give up that easy.

    It's worth the exercise to see if it can be done, whether you choose to use it or not.

    Post a few records

  7. #7
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,724
    I have a sample with Authors and Books (you can use Authors as RepNumbers)

    In the author list below I have given Jones 2 ids - 5 and 12

    Query to get all books for the author regardless of his/her AuthorId (repNumber)
    Code:
    SELECT authors.author_name
    , authors.author_id
    , BOOK.BookTitle
    FROM authors INNER JOIN 
    (BOOK INNER JOIN BOOKAuthors ON
     BOOK.BookId = BOOKAuthors.BookID) ON
     authors.author_id = BOOKAuthors.AuthorId
    WHERE (((authors.author_name) 
    In (select distinct author_name from authors)))
    ORDER BY authors.author_name;
    author_id author_name
    4 samuels
    5 Jones
    6 Alyme
    7 Willington
    8 Arnold
    9 Polivka
    12 Jones

    Results of the query in the attached jpg

    Good luck with your project
    Attached Thumbnails Attached Thumbnails BookAuthorsWithMultipleIds_Results.jpg  

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

Similar Threads

  1. Replies: 5
    Last Post: 04-19-2012, 10:13 AM
  2. Replies: 0
    Last Post: 03-03-2012, 03:43 PM
  3. Replies: 1
    Last Post: 02-04-2012, 02:07 AM
  4. User Prompt for multiple Files
    By ratherbgolfing in forum Programming
    Replies: 1
    Last Post: 01-31-2012, 03:38 PM
  5. Table Values As Query Input?
    By joolio in forum Access
    Replies: 2
    Last Post: 01-05-2010, 07:32 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