Results 1 to 6 of 6
  1. #1
    osscie3 is offline Novice
    Windows 7 64bit Access 2016
    Join Date
    Apr 2018
    Posts
    5

    Macro for printing a certain record from a report based on user input

    Hi all,



    I'd like to write a macro that will print a certain record based on the user inputting the unique ID from the raw data that the report is pulling from. What's the best way to go about doing this? Forgive my newness. I'm used to writing macros in Excel. First time I've written in Access.

    The unique ID in the raw data is labeled "ID". Report name is "Cardholder Dispute". Actually is there a way to have a drop down list of all reports that the user can choose from?


    Thanks in advance. Will be happy to answer additional questions if need be.

  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,518
    How about:

    http://www.baldyweb.com/wherecondition.htm

    You can use a combo with report names with OpenReport (in VBA anyway).
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    osscie3 is offline Novice
    Windows 7 64bit Access 2016
    Join Date
    Apr 2018
    Posts
    5
    Good stuff. I found that page earlier but still unsure how to tweak it. How can I add a spot for a message box to pop up asking the Unique ID as well as which report?

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    Most of us use forms to gather user input, so that's what I'd do. You have more control and can validate the entry before trying to open the report. If you want you can use an InputBox() to gather the input to a variable, then use that in OpenReport.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    osscie3 is offline Novice
    Windows 7 64bit Access 2016
    Join Date
    Apr 2018
    Posts
    5
    I think I figured it out. This is one of those that everything was created before I got here (don't we all love those) and they wanted to see if I could fix it.

    I just built a macro using the OpenReport menu/dialog screen where I set View as Print Preview, left Filter Name blank, Where Condition = [ID] = "whatever record I am trying to pull", Window Mode = Normal.

    Save. Then I double click the Macro and it produces what I want. Easy enough for me.

    Thanks for your input!

  6. #6
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    No problem, glad you have it working.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Replies: 1
    Last Post: 02-16-2018, 03:38 AM
  2. Criteria based on user input
    By vincentsp in forum Queries
    Replies: 4
    Last Post: 03-25-2015, 10:46 AM
  3. Replies: 1
    Last Post: 11-04-2014, 12:07 PM
  4. Replies: 3
    Last Post: 03-11-2013, 05:11 PM
  5. Criteria based on user input
    By Alsail77 in forum Queries
    Replies: 5
    Last Post: 08-16-2012, 02:19 PM

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