Form not hiding

jsic1210

Registered User.
Local time
Yesterday, 22:46
Joined
Feb 29, 2012
Messages
188
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:
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
 
Can I ask why the need to open several forms in one go? And all forms seems to have one field in common, what is that you are trying to accomplish here?
 
Each form is used to populate dates on the separate subreports. The subreports can also be opened on their own, and I didn't know another way to do it. So a subreport might have a date field with a control source of "=Forms!frmYBFinancialUpdateFilter!txtAsOfDate"

I'm sure there's a better way to do it, but at the time, it's all I could think of.
 

Users who are viewing this thread

Back
Top Bottom