Select a Specific Report to print based on date range

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • heart01
    New Member
    • Jun 2010
    • 22

    Select a Specific Report to print based on date range

    I find myself here again...I am using access 2007 and I have three Reports. What I am thinking I would like to do is have a single list box.combo box? whereby I can select a report and then be able to and or select a date range for that report and then be able to print. I hope this makes sense...

    so

    select a specific report

    Product
    Outgoing
    Suppliers

    enter choose date if applicable

    Print that report.


    Can this all be done with one or two clicks of the button as I am thinking that this would be simply placed on my main index? your help in the right direction would be appreciated
  • Jerry Maiapu
    Contributor
    • Feb 2010
    • 259

    #2
    Originally posted by heart01
    I find myself here again...I am using access 2007 and I have three Reports. What I am thinking I would like to do is have a single list box.combo box? whereby I can select a report and then be able to and or select a date range for that report and then be able to print. I hope this makes sense...

    so

    select a specific report

    Product
    Outgoing
    Suppliers

    enter choose date if applicable

    Print that report.


    Can this all be done with one or two clicks of the button as I am thinking that this would be simply placed on my main index? your help in the right direction would be appreciated
    That is possible.
    What you need to do is basically, create a combo box on a unbound form and in the combo box's row source put "Product", "Outgoing", "Suppliers"

    Now create two unbound txt boxes for the two date range.
    To limit the results on the report (based on the date diff entered on the form) you have to put some criteria on the query where the 3 report are based on.

    On the criteria section under your date column in the query you should use this syntax:

    Code:
    Between Forms![your form name]![name of first text box for date1] And Forms![your form name]![name of second text box for date2]
    Now add a command button on the form and on click event do some validation and use
    Code:
    DOCmd.OpenReport
    to open the report based on condition.
    You'll use
    Code:
    If <condition> Else
    vb conditional statements to make sure correct report is opened.

    That is all I think you need to do..

    Hope this helps..

    Comment

    • NeoPa
      Recognized Expert Moderator MVP
      • Oct 2006
      • 32634

      #3
      That's mainly good advice. I would only say that filtering is even easier than indicated.

      No need to make the query link into the form (which can cause problems if/when it's not open). Instead you can build up the filter string in SQL form before passing this string as the WhereCondition parameter of the DoCmd.OpenRepor t() call.

      Similar filtering is covered in Example Filtering on a Form.

      Comment

      • heart01
        New Member
        • Jun 2010
        • 22

        #4
        I appreciate your response - I have the date selection happening but have no idea about linking the selection in the combo box to run and execute the report...I get as far as having the selecton choice available but that is ias far as it goes...

        Comment

        • NeoPa
          Recognized Expert Moderator MVP
          • Oct 2006
          • 32634

          #5
          OK. That's fine.

          It sounds like you haven't read the linked article yet though. I suggest you go there first then, when you have the concept of building the filter string we can tell you how to apply it to opening a report.

          If you get stuck with the string building from the article then come back and explain where you have a difficulty and we can surely clarify.

          Comment

          Working...