Close Form when calling report

scouser

Registered User.
Local time
Today, 19:47
Joined
Nov 25, 2003
Messages
767
I have a main switchboard 'frmMainMenu'. I have a series of cmdbuttons that call various reports. These were working OK. If the report was blank it envoked the 'On No Data' event of the report. However the Access default message then displayed 'The openReportAction was cancelled'. To stop this I have tried to implement 'Stormin Normans' code:

Code:
Private Sub cmdOK_Click()
    On Error GoTo Err_RunReport

DoCmd.OpenReport "rprtOrderAnalysisByServiceType", acViewPreview
DoCmd.Close acForm, Me.Name

Exit_RunReport:
Exit Sub

Err_RunReport:
Select Case Err.Number
Case 2501 'There were no records, so close this report, run the next!
Resume Next
Case Else
MsgBox Err.Number & ": " & Err.Description, , "ERROR " & Err.Source
End Select
Resume Exit_RunReport
End Sub

This works but now how I want frmMainMenu to close when the report is displayed. Then when the report is closed I want the user to be returned to frmMainMenu?

I thought the following in the above would close the main menu:
Code:
DoCmd.Close acForm, Me.Name

Alas the report opens to the side of the main menu?

Any ideas?
Cheers,
Phil.
 
Close form

The problem may be that you open the report before
you call the code to close the form.

Perhaps this will work:

DoCmd.Close acForm, "frmMainMenu"

instead of:

DoCmd.Close acForm, Me.Name
 
Would you want to set the main menus visible property to false when the report opens and then when the report closes simply make the main menu visible again?
 
Cheers Guys

Thanks guys. I will have a dabble and keep you posted.
Many Thanks,
Phil.
 
Set Form to Visible

Would you want to set the main menus visible property to false when the report opens and then when the report closes simply make the main menu visible again?

OK, did this on the rprt Open Event:
Code:
DoCmd.Close acForm, "frmMainMenu", acSaveNo
DoCmd.Maximize

That worked. However the above sets the report size to 'Fit' upon opening. If I zoom in and then close the report 'frmMainMenu' is no longer displayed central, instead it re-opens full screen with the Menu Options on the left and lots of white space to the right (see jpegs).

If I set frmMainMenu to Pop Up 'Yes' it gets rid of this problem, but the form overlaps the default Menu Options at the top of the screen!!

Cheers,
Phil.
 

Attachments

  • Main Menu Normal View.JPG
    Main Menu Normal View.JPG
    56.5 KB · Views: 234
  • Main Menu Off Set.JPG
    Main Menu Off Set.JPG
    61.4 KB · Views: 209
Last edited:
Kinda There

I have decided to leave the frmMainMenu open when the reports are called. That way when the report is closed all is OK.

Suppose you can't have it all!!
Thanks for your help.
Phil.
 

Users who are viewing this thread

Back
Top Bottom