Report Open and Close with Date Prompt

Maddison2_98

New member
Local time
Today, 12:34
Joined
Mar 22, 2004
Messages
5
Hi,

I have a report that when you open it, it will ask for a date range (start date and end date) and person's name, these work fine. You enter the dates, the persons name, and the report pops up. I want to be able to close the report and have the date prompt/name prompt there to enter new dates/names.
Right now I enter the date/name, the report opens, then when I close the report, I have to open the report again to get the date/name prompt. Is there a way to do this without having to do this (Enter dates/name range, open report, close report, click to open report, enter dates/name range, open report, close report, click to open report, date/name prompt, etc. every time.

This is what I have so far:
Option Compare Database

Private Sub Report_Close()
DoCmd.Close acForm, "Date Prompt 1"
DoCmd.Close acForm, "NamePrompt"
End Sub

Private Sub Report_NoData(Cancel As Integer)
On Error GoTo Error
Cancel = True
MsgBox "There is no data for " & Format(Forms![Date Prompt 1]![st_date], "mmm-dd-yyyy") & " to " & Format(Forms![Date Prompt 1]![e_date], "mmm-dd-yyyy")
Exit_Error:
Exit Sub

Error:

Resume Exit_Error
End Sub


Private Sub Report_Open(Cancel As Integer)
DoCmd.OpenForm "Date Prompt 1", , , , , acDialog
DoCmd.OpenForm "NamePrompt", , , , , acDialog
End Sub
 
Use a single form to collect the prompt information and include a run report button on that form. That way you can just change the prompt fields and press the run button.
 
Pat,

Thanks for the reply but I have 6 different reports that use that prompt. If I put a run button on the prompt form it will only open the one form, I'm sorry if I nieve, but how would you do this to be able to run each report from the same prompt and button.

Thanks,
 
There are several ways to handle the problem. Here are two:

The one I use is to list the common reports and let the user select the report they want to run on the same form that I use for data entry.

Another way is to pass the name of the report you want to run as the OpenArgs parameter to the prompting form. Then when the run button is pressed, the program uses the OpenArgs parameter as the name parameter in the OpenReport Method.
 
Pat Hartman said:
There are several ways to handle the problem. Here are two:

The one I use is to list the common reports and let the user select the report they want to run on the same form that I use for data entry.

Another way is to pass the name of the report you want to run as the OpenArgs parameter to the prompting form. Then when the run button is pressed, the program uses the OpenArgs parameter as the name parameter in the OpenReport Method.


Thank you, I will give it a try. If it doesn't work I'm sure you will be reading me again.

Thanks,
 

Users who are viewing this thread

Back
Top Bottom