Coding to use ONE Dialog Box for Various Reports

  • Thread starter Konchetta via AccessMonster.com
  • Start date
K

Konchetta via AccessMonster.com

Greetings All!

I have researched this site to find my problem but can't find a resolution.
My problem is that I have various reports and parameter queries for which I
want to use one Dialog Box which prompts the user to enter the beginning and
ending Fiscal Year. I was about to resort to creating a dialog box form for
each report but i'm sure there is a simpler way to do this. I have the
coding for my OK button of my Form below for one specific report but how
should it be coded so that more than one report can use this dialog box. Or
should there be coding for each report somewhere-else? I hope I am stating
this correctly.
Any assistance would be GREATLY appreciated!

Private Sub OK_Click()
On Error GoTo Err_OK_Click

Dim strMsg As String, strTitle As String
Dim intStyle As Integer

' If Audit Information - 202 report is not being opened for previewing or
printing,
' cause an error. (blnOpening variable is true only when report's Open
event
' is being executed.)
If Not Reports![Audit Information - 202].blnOpening Then Err.Raise 0

' Hide form.
Me.Visible = False

Exit_OK_Click:
Exit Sub

Err_OK_Click:
strMsg = "To use this form, you must preview or print the Audit
Information - 202 Reports from the Database window or Design view."
intStyle = vbOKOnly
strTitle = "Open from Report"

MsgBox strMsg, intStyle, strTitle
Resume Exit_OK_Click


End Sub
 
A

Allen Browne

You cannot use the query dialogs across multiple queries.

Create a form where the user can indicate the date range. You can then
either:
a) Refer to that form's controls in multiple queries, e.g.:
Between [Forms].[Form1].[StartDate] And [Forms].[Form1].[EndDate]
or
b) Use the WhereCondition of OpenReport.

Both techniques are explained in this article:
Limiting a Report to a Date Range
at:
http://allenbrowne.com/casu-08.html
 
K

Konchetta via AccessMonster.com

Thanks Mr. Browne I read the article and try this!!!

Allen said:
You cannot use the query dialogs across multiple queries.

Create a form where the user can indicate the date range. You can then
either:
a) Refer to that form's controls in multiple queries, e.g.:
Between [Forms].[Form1].[StartDate] And [Forms].[Form1].[EndDate]
or
b) Use the WhereCondition of OpenReport.

Both techniques are explained in this article:
Limiting a Report to a Date Range
at:
http://allenbrowne.com/casu-08.html
I have researched this site to find my problem but can't find a
resolution.
[quoted text clipped - 41 lines]
Resume Exit_OK_Click
End Sub
 
K

Konchetta via AccessMonster.com

Mr. Browne,
It looks like Method 2 of your article is what I want to do but how would
this one form work for multiple reports as the first line of the coding ask
for the name of report to open. Do you then just put a comma between the
names of the reports? Or you create an option group as stated at the bottom
of the article? I think that is where Im getting confused!!!

Allen said:
You cannot use the query dialogs across multiple queries.

Create a form where the user can indicate the date range. You can then
either:
a) Refer to that form's controls in multiple queries, e.g.:
Between [Forms].[Form1].[StartDate] And [Forms].[Form1].[EndDate]
or
b) Use the WhereCondition of OpenReport.

Both techniques are explained in this article:
Limiting a Report to a Date Range
at:
http://allenbrowne.com/casu-08.html
I have researched this site to find my problem but can't find a
resolution.
[quoted text clipped - 41 lines]
Resume Exit_OK_Click
End Sub
 
A

Allen Browne

How about an option group on the form, where the user selects the report to
open.

If the option group is named grpReport, and the option buttons in the group
are named opt1 and opt2, you would replace the line:
strReport = "rptSales"
with this:
Select Case Me.grpReport.Value
Case Me.opt1.OptionValue
strReport = "rptSales"
Case Me.opt2.OptionValue
strReport = "Report2"
Case Else
MsgBox "Oops: didn't handle the report name."
End Select

Alternatively, if you wanted to just open a bunch of report without the user
selecting one, just issue an OpenReport for each one at the end of the code,
i.e.:
DoCmd.OpenReport "rptSales", acViewPreview, , strWhere
DoCmd.OpenReport "Report2", acViewPreview, , strWhere
DoCmd.OpenReport "Report3", acViewPreview, , strWhere

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

Konchetta via AccessMonster.com said:
Mr. Browne,
It looks like Method 2 of your article is what I want to do but how would
this one form work for multiple reports as the first line of the coding
ask
for the name of report to open. Do you then just put a comma between the
names of the reports? Or you create an option group as stated at the
bottom
of the article? I think that is where Im getting confused!!!

Allen said:
You cannot use the query dialogs across multiple queries.

Create a form where the user can indicate the date range. You can then
either:
a) Refer to that form's controls in multiple queries, e.g.:
Between [Forms].[Form1].[StartDate] And [Forms].[Form1].[EndDate]
or
b) Use the WhereCondition of OpenReport.

Both techniques are explained in this article:
Limiting a Report to a Date Range
at:
http://allenbrowne.com/casu-08.html
I have researched this site to find my problem but can't find a
resolution.
[quoted text clipped - 41 lines]
Resume Exit_OK_Click
End Sub
 
K

Konchetta via AccessMonster.com

Thank you so much Mr. Browne. Will try this and see if I do it correctly so
that it works!!


Allen said:
How about an option group on the form, where the user selects the report to
open.

If the option group is named grpReport, and the option buttons in the group
are named opt1 and opt2, you would replace the line:
strReport = "rptSales"
with this:
Select Case Me.grpReport.Value
Case Me.opt1.OptionValue
strReport = "rptSales"
Case Me.opt2.OptionValue
strReport = "Report2"
Case Else
MsgBox "Oops: didn't handle the report name."
End Select

Alternatively, if you wanted to just open a bunch of report without the user
selecting one, just issue an OpenReport for each one at the end of the code,
i.e.:
DoCmd.OpenReport "rptSales", acViewPreview, , strWhere
DoCmd.OpenReport "Report2", acViewPreview, , strWhere
DoCmd.OpenReport "Report3", acViewPreview, , strWhere
Mr. Browne,
It looks like Method 2 of your article is what I want to do but how would
[quoted text clipped - 24 lines]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top