Issue trying to get Report to run via a Drop Down box form linked

H

HelenR

I've created a form, query and report. The Form contains a combo box (which
lookups up a table list). When items are selected within the form, and then
the "OK" button is pressed, it goes away and processes the query, returning
items as selected in the Form.

I want to run a report now, that also can be restricted according to items
selected in the report. The following error message comes up: " Compile
Error: Expected variable or procedure, not module"


I've put the following code in:
Private Sub Report_Open(Cancel As Integer)
' Set public variable to true to indicate that the report
' is in the Open event
bInReportOpenEvent = True

'Open MonthlyReports
DoCmd.OpenForm , "MonthlyReports", , , , acDialog

'Cancel Report if user clicked the cancel Button

If IsLoaded("MonthlyReports") = False Then Cancel = True

' Set public variable to false to indicate that the
' Open event is completed
bInReportOpenEvent = False

End Sub

and this supporting module:



Option Compare Database
Option Explicit
Public bInReportOpenEvent As Boolean ' Is report in the Open event?

Function IsLoaded(ByVal strFormName As String) As Boolean
' Returns True if the specified form is open in Form view or Datasheet view.
Dim oAccessObject As AccessObject
Set oAccessObject = CurrentProject.AllForms(strFormName)
If oAccessObject.IsLoaded Then
If oAccessObject.CurrentView <> acCurViewDesign Then
IsLoaded = True
End If
End If
End Function

Can anyone help me to get this working?
 
G

G. Vaught

If you are trying to open a report, then you need to change the
DoCmd.OpenForm to OpenReports.
 
H

HelenR

Not quite...

What I want to happen is when the report is first opened for it to launch
the form I have built, which allows the user to select from a drop down list
what they want to see. I created a form to do this.

Once they press OK I want the report to return data applicable to what was
actually selected in the parameter. (the below is a bit confusing as form is
called "MonthlyReports").
 

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