S
Sandy
Getting Run time error in code : Run Time Error '2467' the expression u have
entered refers to an object that is closed or does'nt exist.
Set oAccessObject = CurrentProject.AllForms(strFormName)
when we open report..
(Am working on MDB file)
Am trying to build parameter form which accepts value and then process
reports. This i have done as per lessons in MS Access Coding where codes have
been writen in form/report and module created.
Following are the codes :
Module Level: Module created by name of Report Parameter
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
Under Report "Test Appl" following codes defined in open and close event
Private Sub Report_Open(Cancel As Integer)
'Set public variable to true to indicate that the report
'is in the Open Even
bInReportOpenEvent = True
'Open Daily Report
DoCmd.OpenForm "Options Rpt Daily Report", , , , , acDialog
'Cancel Report if user clicked the Cancel Button
If IsLoaded("Test Appl") = False Then Cancel = True
'Set the public variable to false to indicate the
' Open event is completed
bInReportOpenEvent = False
End Sub
In Form "Options Rpt Daily Report" following codes defined in ok, cancel and
open form event
Option Compare Database
Private Sub Command11_Click()
DoCmd.Close
End Sub
Private Sub Form_Open(Cancel As Integer)
If Not bInReportOpenEvent Then
'IF we re not called from the Report
MsgBox "For use from the Daily Report Only", vbOKOnly
Cancel = True
End If
Form_Open_Exit:
Exit Sub
End Sub
Private Sub Command10_Click()
Me.Visible = False
End Sub
Report is liked to query "Qry Rpt App" where parameters are mentioned and
these parameters are linked with above form
entered refers to an object that is closed or does'nt exist.
Set oAccessObject = CurrentProject.AllForms(strFormName)
when we open report..
(Am working on MDB file)
Am trying to build parameter form which accepts value and then process
reports. This i have done as per lessons in MS Access Coding where codes have
been writen in form/report and module created.
Following are the codes :
Module Level: Module created by name of Report Parameter
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
Under Report "Test Appl" following codes defined in open and close event
Private Sub Report_Open(Cancel As Integer)
'Set public variable to true to indicate that the report
'is in the Open Even
bInReportOpenEvent = True
'Open Daily Report
DoCmd.OpenForm "Options Rpt Daily Report", , , , , acDialog
'Cancel Report if user clicked the Cancel Button
If IsLoaded("Test Appl") = False Then Cancel = True
'Set the public variable to false to indicate the
' Open event is completed
bInReportOpenEvent = False
End Sub
In Form "Options Rpt Daily Report" following codes defined in ok, cancel and
open form event
Option Compare Database
Private Sub Command11_Click()
DoCmd.Close
End Sub
Private Sub Form_Open(Cancel As Integer)
If Not bInReportOpenEvent Then
'IF we re not called from the Report
MsgBox "For use from the Daily Report Only", vbOKOnly
Cancel = True
End If
Form_Open_Exit:
Exit Sub
End Sub
Private Sub Command10_Click()
Me.Visible = False
End Sub
Report is liked to query "Qry Rpt App" where parameters are mentioned and
these parameters are linked with above form