views:

48

answers:

0

I have an Access 2003 MDB where I would like to present a small form for the user to input two parameters "Start Date" and "End Date". Thanks to another Stack Overflow user ("Kevin Ross"), I learned how to embed the form control directly in the query that is used by the report I would like to display.

SELECT q1.CasesAssigned, q2.WarningsIssued  
FROM 
    (SELECT COUNT(*) AS CasesAssigned 
    FROM vwCaseDetail 
    WHERE DateAssigned Between [Forms]![frmReporting]![txtStartDate] 
        AND [Forms]![frmReporting]![txtEndDate]) as q1,  
    (SELECT COUNT(*) AS WarningsIssued 
    FROM vwWarningDetail 
    WHERE DateIssued Between [Forms]![frmReporting]![txtStartDate] 
        AND [Forms]![frmReporting]![txtEndDate]) as q2

I have tried two different ways to open the report and pass the users input:

  1. After the user enters parameters I call DoCmd.OpenReport "myReport", acViewPreview. The problem here is that the reports opens and close so fast I never even see it. Ideally I would like to close the input collection form and then open the report.

  2. Inside the Report_Open event I have code that opens the form that collect the users input. The input collection form opens, however I still get prompted by the report to enter in the two parameters. The report does not seem to be gathering the parameters from the input collection form.

Any suggestions on the proper way to pass data collected on a form to a report? Thank you.