Results 1 to 4 of 4
  1. #1
    5 Star Lounger
    Join Date
    May 2003
    Location
    Sheffield, Yorkshire
    Posts
    951
    Thanks
    1
    Thanked 0 Times in 0 Posts

    One Print button for different reports

    I have a form in which we record dispatch data. There is a command button on the form that prints a report containing the current record. Until recently, this has been adequate, but now we have to have another report, with a slightly different layout, dependent on certain criteria. Rather than have multiple buttons to print the report, I would like to put code on the form, to determine which report to print (ie change the stDocName accordingly). So, basically, if customer is A, print report 1, if customer is B, print report 2, else print report 3. I tried if, then, else, but it doesn't seem to work.

  2. Subscribe to our Windows Secrets Newsletter - It's Free!

    Get our unique weekly Newsletter with tips and techniques, how to's and critical updates on Windows 7, Windows 8, Windows XP, Firefox, Internet Explorer, Google, etc. Join our 480,000 subscribers!

    Excel 2013: The Missing Manual

    + Get this BONUS — free!

    Get the most of Excel! Learn about new features, basics of creating a new spreadsheet and using the infamous Ribbon in the first chapter of Excel 2013: The Missing Manual - Subscribe and download Chapter 1 for free!

  3. #2
    Super Moderator
    Join Date
    Aug 2001
    Location
    Evergreen, CO, USA
    Posts
    6,492
    Thanks
    3
    Thanked 41 Times in 41 Posts
    Since you have three different categories, you should be able to use the If, ElseIf, Else construct to implement the different reports. But you might also consider using the Select Case construct which lets you deal with a number of possibilities. If you continue to struggle, post the code you are trying to use, and someone can probably resolve your issues.
    Wendell

  4. #3
    2 Star Lounger HiTechCoach's Avatar
    Join Date
    Sep 2011
    Location
    Oklahoma City, OK
    Posts
    162
    Thanks
    0
    Thanked 24 Times in 24 Posts
    The way I like to handle this is to use a combo box next to the the command button that selects the report format to print. You can have once of the columns of the combo box hold the actual report name.

    For example if the report name is in column 3 (index = 2) of the combo box then use:

    Code:
    stDocName = Me.cboReportToPrint.Column(2)
    Boyd Trimmell aka HiTechCoach (Access Information here)
    Microsoft MVP - Access Expert
    "If technology doesn't work for people, then it doesn't work."

  5. The Following User Says Thank You to HiTechCoach For This Useful Post:

    robm (2013-10-09)

  6. #4
    5 Star Lounger
    Join Date
    May 2003
    Location
    Sheffield, Yorkshire
    Posts
    951
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Thanks guys. Ended up using Select Case. I tried this before, but for some reason it didn't work. This time it has, even though I haven't done anything different. Thanks again.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •