Parameter dialog form to open report?

K

Kevin

I created a form called 'frmEstimateSelector', which is a dialog box that
allows users to select 2 parameters (ProjectName & BidNUmber) from combo
boxes for a parameter query called 'EstimateDetailEXP'. It works properly
and returns the expected results with the query. I also have a report called
'EstimateDetail', that is intended to report that query's results.

How do I open frmEstimateSelector when I run the EstimateDetail report? I'm
assuming it's part of the On Open Event, but don't know what code to write.
I have very little VBA experience and am sort of learning as I go. If I am
way off base with this, please set me straight! Any help is greatly
appreciated!
 
K

Kevin

I have reproduced that code into my form's On Open event, other than of
course changing "Sales By Year Dialog" to my "frmEstimateSelector". When I
try to run the report, I get an error message "Compile Error - Sub or
Function Not Defined", and the "IsLoaded" toward the end of the code is
highlighted in gray. When I click the OK button, the first line "Private Sub
Report_Open(Cancel As Integer)" is highlighted in yellow.

I'm lost at this point. What might be the problem? Again, I appreciate the
help!
Kevin
 
F

fredg

I have reproduced that code into my form's On Open event, other than of
course changing "Sales By Year Dialog" to my "frmEstimateSelector". When I
try to run the report, I get an error message "Compile Error - Sub or
Function Not Defined", and the "IsLoaded" toward the end of the code is
highlighted in gray. When I click the OK button, the first line "Private Sub
Report_Open(Cancel As Integer)" is highlighted in yellow.

I'm lost at this point. What might be the problem? Again, I appreciate the
help!
Kevin
Which version of Access are you using?
Access 97 does not include an IsLoaded function by default.
You must copy it from the Northwind Utility module and paste it into a
module in your computer.

If you are using Access 2000 or newer, then, instead of
If Not IsLoaded("frmEstimateSelector") then ....
use:

If Not CurrentProject.AllForms("frmEstimateSelector").IsLoaded Then
Do something here
Else
Do something else
End If
 
K

Kevin

fredg said:
Which version of Access are you using?
Access 97 does not include an IsLoaded function by default.
You must copy it from the Northwind Utility module and paste it into a
module in your computer.

If you are using Access 2000 or newer, then, instead of
If Not IsLoaded("frmEstimateSelector") then ....
use:

If Not CurrentProject.AllForms("frmEstimateSelector").IsLoaded Then
Do something here
Else
Do something else
End If

I am using Access 2002 (which is in 2000 file format), so it should work
shouldn't it? If I use the other coding you suggested, what do I include
where you wrote "Do something here" and "Do something else"?
Thanks once again!
 
F

fredg

On Mon, 18 Apr 2005 12:31:08 -0700, Kevin wrote:

*** snipped**
I am using Access 2002 (which is in 2000 file format), so it should work
shouldn't it? If I use the other coding you suggested, what do I include
where you wrote "Do something here" and "Do something else"?
Thanks once again!

Please copy and paste your current Open event code.
I'll look at it and change it as needed.
 
A

Albert D. Kallal

I would suggest that your code simply launch the prompt screen, and then a
button on the prompt screen then launches the report.

In fact, the real nice thing about this approach is often you build up some
fairly complex prompts..and need to apply them to MORE then one report.

Take a look at the following prompt screens of mine..and note how a good
many of them have the ability to launch more then one report. So, don't make
the report launch the form....simply launch the form..and have that form
open the reports as needed.

http://www.members.shaw.ca/AlbertKallal/ridesrpt/ridesrpt.html
 
K

Kevin

Please copy and paste your current Open event code.
I'll look at it and change it as needed.
Here is the code in the Open event:

Private Sub Report_Open(Cancel As Integer)
' Open frmEstimateSelector form.
' IsLoaded function (defined in Utility Functions module) determines
' if specified form is open.

Dim strDocName As String

strDocName = "frmEstimateSelector"
' Set public variable to true to indicate that the report
' is in the Open event
blnOpening = True

' Open form.
DoCmd.OpenForm strDocName, , , , , acDialog

' If frmEstimateSelector form isn't loaded, don't preview or print report.
' (User clicked Cancel button on form.)
If IsLoaded(strDocName) = False Then Cancel = True

' Set Public variable to False, signifying that Open event is finished.
blnOpening = False
End Sub

Thanks for taking the time to look at this Fred!
 
F

fredg

Here is the code in the Open event:

Private Sub Report_Open(Cancel As Integer)
' Open frmEstimateSelector form.
' IsLoaded function (defined in Utility Functions module) determines
' if specified form is open.

Dim strDocName As String

strDocName = "frmEstimateSelector"
' Set public variable to true to indicate that the report
' is in the Open event
blnOpening = True

' Open form.
DoCmd.OpenForm strDocName, , , , , acDialog

' If frmEstimateSelector form isn't loaded, don't preview or print report.
' (User clicked Cancel button on form.)
If IsLoaded(strDocName) = False Then Cancel = True

' Set Public variable to False, signifying that Open event is finished.
blnOpening = False
End Sub

Thanks for taking the time to look at this Fred!

Private Sub Report_Open(Cancel As Integer)

Dim strDocName As String
strDocName = "frmEstimateSelector"

blnOpening = True

DoCmd.OpenForm strDocName, , , , , acDialog

If Not CurrentProject.AllForms("frmEstimateSelector").IsLoaded Then
Cancel = True
End If

blnOpening = False

End Sub
 

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