Hide the Switchboard form while a Report is Loading

whdyck

Registered User.
Local time
Today, 14:28
Joined
Aug 8, 2011
Messages
169
I'm using Access 2003.

I have a report that uses a form to collect parameters before generating the report.

Here's the VBA code in the report's Open event:

Private Sub Report_Open(Cancel As Integer)

' Set public variable to true to indicate that the report is in the Open event
GblnInReportOpenEvent = True

' Open Dialog to collect parms
DoCmd.OpenForm "frmRptClaimsByDestinationCountryDialogue", , , , , acDialog

' Cancel Report if User Clicked the Cancel Button
If fIsLoaded("frmRptClaimsByDestinationCountryDialogue") = False Then
Cancel = True
Else
DoCmd.Maximize
End If

' Set public variable to false to indicate that the Open event is completed
GblnInReportOpenEvent = False

End Sub

When the DoCmd.Maximize command fires, the report does indeed maximize; however, the Switchboard form also displays in the top left corner of the blank report until the data is retrieved.

Is there a way to hide the Switchboard form before the report has its data?

Thanks.

Wayne
 
This should work for you. Make sure to make it visible again in the report's close event.
Code:
Private Sub Report_Open(Cancel As Integer)

' Set public variable to true to indicate that the report is in the Open event
GblnInReportOpenEvent = True

[B][COLOR=red]' Make switchboard invisible[/COLOR][/B]
[B][COLOR=red]Forms!FormNameHere.Visible = False[/COLOR][/B]
[B][COLOR=red]DoEvents[/COLOR][/B]

' Open Dialog to collect parms
DoCmd.OpenForm "frmRptClaimsByDestinationCountryDialogue", , , , , acDialog

' Cancel Report if User Clicked the Cancel Button
If fIsLoaded("frmRptClaimsByDestinationCountryDialogu e") = False Then
Cancel = True
Else
DoCmd.Maximize
End If

' Set public variable to false to indicate that the Open event is completed
GblnInReportOpenEvent = False

End Sub
 
This should work for you. Make sure to make it visible again in the report's close event.
Code:
[B][COLOR=red]' Make switchboard invisible[/COLOR][/B]
[B][COLOR=red]Forms!FormNameHere.Visible = False[/COLOR][/B]
[B][COLOR=red]DoEvents[/COLOR][/B]

Beautiful! Thanks, Bob.

BTW, do you think the DoEvents command is necessary? (I've seen differing viewpoints on that.)

Wayne
 
Beautiful! Thanks, Bob.

BTW, do you think the DoEvents command is necessary? (I've seen differing viewpoints on that.)

Wayne

You can try it without the DoEvents. Some things will not happen while in a procedure if you don't include DoEvents, so it may not refresh the screen so it would look like the form is still maximized and there when it isn't until the event was done.
 

Users who are viewing this thread

Back
Top Bottom