Hello,
I am trying to open a report (with subreports) from a form. When the report opens, I want the form to hide, which most of the time does. Sometimes, though, it won't hide when the report opens. So, I even created an error handler, and moved that part of the code to SubExit section, but the problem still occasionally occurs. Has anyone had this problem before? Here is my code:
I am trying to open a report (with subreports) from a form. When the report opens, I want the form to hide, which most of the time does. Sometimes, though, it won't hide when the report opens. So, I even created an error handler, and moved that part of the code to SubExit section, but the problem still occasionally occurs. Has anyone had this problem before? Here is my code:
Code:
Dim strWhere As String
Dim strDate As String
Dim strDist As String
On Error GoTo ErrHandler
strDate = "=DateSerial(" & Year(Me.txtAsOfDate) & "," & Month(Me.txtAsOfDate) & "," & Day(Me.txtAsOfDate) & ")"
strWhere = "YearEnd = " & Year(Me.txtAsOfDate) - 1
'Open filters
'YB Financial Update
DoCmd.OpenForm "frmYBFinancialUpdateFilter", , , , , acHidden
With Forms!frmYBFinancialUpdateFilter
.txtAsOfDate = Me.txtAsOfDate
.Visible = False
End With
'New Revenue Statistics - YB
DoCmd.OpenForm "frmYBNewRevenueStatsFilter", , , , , acHidden
With Forms!frmYBNewRevenueStatsFilter
.txtAsOfDate = Me.txtAsOfDate
.Visible = False
End With
'New Revenue Statistics - Index
DoCmd.OpenForm "frmIndexNewRevenueStatsFilter", , , , , acHidden
With Forms!frmIndexNewRevenueStatsFilter
.txtAsOfDate = Me.txtAsOfDate
.Visible = False
End With
'New Revenue By Region - YB
DoCmd.OpenForm "frmYBNewRevenueByRegionFilter", , , , , acHidden
With Forms!frmYBNewRevenueByRegionFilter
.txtAsOfDate = Me.txtAsOfDate
.Visible = False
End With
'New Revenue By Region - Index
DoCmd.OpenForm "frmIndexNewRevenueByRegionFilter", , , , , acHidden
With Forms!frmIndexNewRevenueByRegionFilter
.txtAsOfDate = Me.txtAsOfDate
.Visible = False
End With
'Internal Sales
DoCmd.OpenForm "frmInternalSalesFilter", , , , , acHidden
With Forms!frmInternalSalesFilter
.txtAsOfDate = Me.txtAsOfDate
.Visible = False
End With
'CPU
DoCmd.OpenForm "frmCPUWeeklyFilter", , , , , acHidden
With Forms!frmCPUWeeklyFilter
.txtAsOfDate = Me.txtAsOfDate
.Visible = False
End With
'Unlimited CPU
DoCmd.OpenForm "frmUnlimitedCPUWeeklyFilter", , , , , acHidden
With Forms!frmUnlimitedCPUWeeklyFilter
.txtAsOfDate = Me.txtAsOfDate
.Visible = False
End With
'Index Financial Update
DoCmd.OpenForm "frmIndexFinancialUpdateFilter", , , , , acHidden
With Forms!frmIndexFinancialUpdateFilter
.txtAsOfDate = Me.txtAsOfDate
.Visible = False
End With
'Open in print preview
DoCmd.OpenReport "rptWeeklyReport", acViewPreview, , strWhere
DoCmd.RunCommand acCmdFitToWindow
SubExit:
'Hide filter
Forms!frmWeeklyReportFilter.Visible = False
Exit Sub
ErrHandler:
MsgBox Error$
GoTo SubExit