Results 1 to 7 of 7
  1. #1
    Join Date
    Apr 2007
    Location
    Stalybridge, Manchester
    Posts
    273

    Unanswered: List Box to Report

    Hi, Is it possible to have a list box with different report names in, and when you select on one it then produces the report, and ask for a report date (From and To)

    Jez

  2. #2
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    Yes.

    Which bit are you struggling with?
    Testimonial:
    pootle flump
    ur codings are working excelent.

  3. #3
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    yes
    you can use the appropriate event to call the selected report using the macro command something like DoCmd openrrport<blah>,<blah>,<blah>

    you can set a date band as either a parameter on the DoCmd statement, or you can pull the values to be used as aprt of the reports on open event in vba code

    personally I've used the latter construct quite often.
    you have a form which allows the user to select which parameters they want to use (that form includes any date validations or other filter logic), either that form has report / form list box or it sets values in the switchboard which then acts as a clearing house for calling reports/forms using the values form the parameter form. The clearing house form automatically sets valid defaults, and will only accept valid parameters so you know your reports / forsm will always have consistent data. Each form or report requiring parameters attemtps to load parameters on startup. As the parameters are set on a central form all subsequent reports / forms will use the same set of parameters until the user closes the main form or changes the params.. its works very well for say financial period reporting, or if you have to run a set of reports or some reports from a document set.
    I'd rather be riding on the Tiger 800 or the Norton

  4. #4
    Join Date
    Apr 2007
    Location
    Stalybridge, Manchester
    Posts
    273
    I understand the DoCmd OpenReport but if the list box contains a list of different reports to show, how if I select say the third in the list will I get the correct report?
    Also on the form with the list box if I have txt box where the user inputs dates can this be then fed into code to pick up when a report is selected in the list box?

    Jez

  5. #5
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    put some code behind the list/combo box's on click event
    pass the value from the list/combo box to the docmd statement.
    I'd rather be riding on the Tiger 800 or the Norton

  6. #6
    Join Date
    Apr 2007
    Location
    Stalybridge, Manchester
    Posts
    273
    As I said with an earlier thread, I am new to this access building database's and not quite understanding what you mean by your last thread
    Could you explain the pass the value from the list box to the DoCmd from the list box.

    eg I have in my list box
    Report1
    Report2
    Report3
    Report4
    I want the user to click on one of the report numbers and then input a date range for the report and click select and the report then show on screen, and if the want to view another report then click on one of the other selections whichever is relevant for their choice

    Jez

  7. #7
    Join Date
    Sep 2006
    Posts
    265
    I put the reports into a table and gave the each Report a code. When I call the reports I ask for the Code. Then I created a Dialog Form with amongst other variables, dates to qualify the reports: StartDate and EndDate. All the reports defer to this Dialog Form and the dates can be enbedded into the underlying Queries. Calling the report from a Command Button using:

    Dim SalesReport As String
    SalesReport = .[Sales Report Desc]

    DoCmd.OpenReport SalesReport, acViewPreview, , SalesReports_Criteria

    I hide the Dialogue Form before the call:

    DoCmd.OpenForm "Sales Dialogue Reports", acNormal, , , , acHidden

    On Report close I call the Dialogue Form so that users if required can ask for another report:

    DoCmd.OpenForm "Sales Dialogue Reports", acNormal, "", "", , acNormal

    Whilst you could do this in a list I needed to determine variables as some of the reports are in summary format whilst other show details. A second Command Button is for summary reports and this is handled by:

    with CodeContextObject
    If .[Sales Summary] <> True

    Dim SalesReport As String
    SalesReport = .[Sales Report Desc] & " Summary"
    DoCmd.OpenReport SalesReport, acViewPreview

    Simon

Posting Permissions

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