Close Report, Open Form (1 Viewer)

mrabrams2

Registered User.
Local time
Today, 02:02
Joined
Apr 29, 2003
Messages
54
Sounds easy. Actually, it is. That is, when the user closes the report with the 'Close' button.
But when they close the report using the 'X' in the upper right hand corner though....

Here is the code I have in the report's Close Event:

Private Sub Report_Close()
Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "MENU"
DoCmd.OpenForm stDocName, , , stLinkCriteria
End Sub

This code does not work if you close the report with the 'X'.

Can I code it to close the report & open the form even if the user click's the 'X' ? (I have code to remove the 'X' and the toolbars, but then there'd be no way out !!)

Thank you for any suggestions.

Michael
 

pdx_man

Just trying to help
Local time
Yesterday, 23:02
Joined
Jan 23, 2001
Messages
1,347
Well ... what version of Access are you using? It works fine for me. What values are you putting in stLinkCriteria? Try dropping everything after stDocName and just see if you can get it to open. Add a Breakpoint on the stDocName = "MENU" line to see if it is being run consistantly. You may have dangling error trapping.
 

mrabrams2

Registered User.
Local time
Today, 02:02
Joined
Apr 29, 2003
Messages
54
what version of Access are you using?
Access '97

Open a report in Preview.

You will have 4 ways to "Close" the report.

1 - File/Close
2 - The 'X' on the FAR right upper corner (This is the Window's 'X')
3 - The 'X' on the NEAR right upper corner (This is the Access 'X')
4 - The word 'Close' on the Print Preview Toolbar

If I click #1, #3 or #4, the code works fine.

If I click #2 it closes the application.

This is a Windows API situation, I believe, so I am looking for a workaround.

Thank you for your help !

Michael
 

pdx_man

Just trying to help
Local time
Yesterday, 23:02
Joined
Jan 23, 2001
Messages
1,347
Yeah, you are talking about something totally different. You posted about closing the report but in fact you are talking about when closing the Access application, you want a the form to come up instead of closing Access ... is that right? Just do a search on these forums for Application Quit, or something like that. I believe ghudson had something a while back on this.
 

mrabrams2

Registered User.
Local time
Today, 02:02
Joined
Apr 29, 2003
Messages
54
Thank you very much. I will begin my search !!

Michael
 

Users who are viewing this thread

Top Bottom