Results 1 to 4 of 4
  1. #1
    SundayST is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2015
    Posts
    2

    Can Microsoft Access Choose Which Report to Run Using a Macro?

    I have an MS Access 2010 database that has several different versions of a report for Model details of cars and trucks. The reports are similar in some ways. (Both have stats regarding an engine and the capacity of a gas tank, for example.) But the reports are different in other ways. (The car would not have the length of a pick-up bed listed, for example.)



    I have a Form where the user inputs the Model Number, and all my queries are based on that Model Number to populate the reports.

    I would like for the database to...when a user puts in Model Number and clicks "Run Report"...run a Report and print it, but I want it to base the selection of which Report to run on two things:

    1. Is the Model a Car or a Truck.
    2. Is the Model 4-wheel-drive or 2-wheel-drive.

    Those are both fields in my database, and I have 4 different forms corresponding to the 4 possible combinations. (2WD Car, 4WD Car, 2WD Truck, 4WD Truck). Those fields are associated with each Model Number, so once a user selects the Model Number, then Access should be able to say, "Oh, that is a 2WD Car, so print only the report for 2-Wheel-Drive Cars".

    Is this possible? I have some coding skill, but am not an expert by any means.

    Thanks for any help!

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,825
    This will require If Then Else conditional constructs in code.

    Have the user select model number from a combobox list. The combobox RowSource can include multiple fields that have info about the vehicle. http://datapigtechnologies.com/flash...combobox3.html

    Code can reference the columns for the appropriate info. I don't use macros. Example in VBA:

    If Me.cbxVehicle.Column(1) = "Car" Then
    ...
    Else
    ...
    End If
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    SundayST is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2015
    Posts
    2
    Thanks.

    Your answer got me thinking, since I really need it to run a Macro (to build all the tables behind the report based on the Model that is selected). I made different buttons, at the same position (so the user can't tell they are different buttons, since they are identical), that are only visible when a Model meeting the right criteria is selected. If the user picks a Model that is "4WD" and "Car", then the only button that says "Run Report" that appears is the one corresponding to the "4WD Car" version of the report.

    THANKS! Sometime you just need a sounding board to get the ideas going.

    Great help!

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,825
    That's another way, although don't think I would choose it.

    What do you mean by "to build all the tables"? Tables should already exist.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

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

Similar Threads

  1. Replies: 13
    Last Post: 10-06-2015, 09:12 AM
  2. Replies: 5
    Last Post: 03-25-2012, 12:31 PM
  3. Microsoft Access 2010 - Filtered report?
    By keaccesshelp in forum Reports
    Replies: 1
    Last Post: 02-21-2012, 03:36 PM
  4. Replies: 1
    Last Post: 09-13-2011, 01:52 PM
  5. Replies: 1
    Last Post: 05-05-2011, 02:54 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