I use TreeView as a menu to open forms, reports. I'm stuck in the opening reports which use a dialog form to enter date before.
Problem : On click to open report a dialog form opens to enter date for report, but when I close dialog form without entering data to open report I get error "OpenReport action was canceled. " My actions don't reach error handling. After line "bInReportOpenEvent = False" get error. Can you suggest something how to solve it.
Private Sub tvw_NodeClick(ByVal Node As MSComctlLib.Node)
On Error GoTo Err_tvw_NodeClick
DoCmd.OpenReport "Profit", acViewPreview
Exit_tvw_NodeClick:
Exit Sub
Err_tvw_NodeClick:
Resume Exit_tvw_NodeClick
End sub
I tried to write error trapping something like this, but nothing helped, I get the same error before reaching error handler:
Private Sub Report_Open(Cancel As Integer)
On Error GoTo ErrHandler
bInReportOpenEvent = True
DoCmd.OpenForm "dateinterval", , , , , acDialog
If IsLoaded("dateinterval") = False Then Cancel = True
bInReportOpenEvent = False
Egress:
Exit Sub
ErrHandler:
Select Case Err.Number
Case 2501
Case Else
MsgBox "goog"
End Select
Resume Egress
End Sub
Public bInReportOpenEvent As Boolean
Function IsLoaded(ByVal strFormName As String) As Boolean
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
Problem : On click to open report a dialog form opens to enter date for report, but when I close dialog form without entering data to open report I get error "OpenReport action was canceled. " My actions don't reach error handling. After line "bInReportOpenEvent = False" get error. Can you suggest something how to solve it.
Private Sub tvw_NodeClick(ByVal Node As MSComctlLib.Node)
On Error GoTo Err_tvw_NodeClick
DoCmd.OpenReport "Profit", acViewPreview
Exit_tvw_NodeClick:
Exit Sub
Err_tvw_NodeClick:
Resume Exit_tvw_NodeClick
End sub
I tried to write error trapping something like this, but nothing helped, I get the same error before reaching error handler:
Private Sub Report_Open(Cancel As Integer)
On Error GoTo ErrHandler
bInReportOpenEvent = True
DoCmd.OpenForm "dateinterval", , , , , acDialog
If IsLoaded("dateinterval") = False Then Cancel = True
bInReportOpenEvent = False
Egress:
Exit Sub
ErrHandler:
Select Case Err.Number
Case 2501
Case Else
MsgBox "goog"
End Select
Resume Egress
End Sub
Public bInReportOpenEvent As Boolean
Function IsLoaded(ByVal strFormName As String) As Boolean
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