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?
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?