Menu question

  • Thread starter Thread starter Tony Williams
  • Start date Start date
T

Tony Williams

I have a close button on a number of my forms behind which is code that
shows a message box depending upon what action the user takes. However if
the user closes the form using File - Close from the menu then the form
closes but there are no messages. Is there a way to get the messages to
appear no matter how the form is closed?
TIA
Tony Williams
 
Move the code to the form's Close eventhandler but leave
the DoCmd.Close statement in the close button's click
eventhandler.

Hope This Helps
Gerald Stanley
 
Thanks Gerald that doesn't seem to work. What I want to happen is that the
user gets the same message no matter how they close the form. I've disabled
the X Close property on the form itself in the top right hand corner but the
code doesn't work if the user uses the Access File Menu Close option even
with the code in the On Close event.
Am I missing something? Is it possible to add code to the Access File menu
options?
Tony
 
Are you sure that the code on the form's Close event
handler is not being invoked when you use the standard
File->Close menu option? Have you set a breakpoint to step
through the code?
I have set up a trial form on my machine under Access 2003
and the code in Form_Close is getting invoked when I click
on File->Close

Hope This Helps
Gerald Stanley MCSD
 
Hi Gerald. Here is the code I have in the OnClose event of the form which is
the code I have on the Close button

If Me.NewRecord Then
If vbYes = MsgBox("Are you sure you want to save this record?", 36, "Enter
New Record") Then
DoCmd.Requery "Docnumtxt"
DoCmd.RunCommand acCmdSaveRecord
Else
Me.Undo
Cancel = True
End If
End If

Am I doing something here wrong or missing something. This works on the
Close button.
Thanks.
PS I am a newbie and not sure how to setup the breakpoint sounds a useful
tool can you point me to which help file I can read up on that?

Thanks again
Tony
 
To set a breakpoint, position the mouse in the left-hand
frame alongside the line of code you wish to break at. The
mouse should change to an arrow pointing North-West. Click
on the mouse and a brown circle should appear in the frame.
This is the breakpoint.

When the code is running and the breakpoint is reached, the
focus will switch to the VB Editor and the line will be
highlighted in Yellow. You can then step though each line
of code by pressing F8 function key. There are also
various options available through the Debug Menu.

Hope This Helps
Gerald Stanley MCSD
 
Back
Top