on close event

R

Richard

Hi

I am trying to capture changes when the user closes with the form's close
button. What I did was at the onclose event, if changes were made, call up a
message box asking if they want to save.

The problem is that the save procedure has a validation code that checks for
a null value in a certain text box; if so it will stop the procedure and
focus on the textbox. In the onclose event it just closes the form. How
would I overcome this? What event fires when the user closes using the close
button at the top right hand corner of the form?

Thanks in advance
Richard
 
B

Bill Edwards

The unload event will run when a user attempts to close a form:
To see how this works you could put code in the unload event similar to:
IF msgbox("Close form", vbYesNo) = vbNo then
Cancel = true
end if

But a better place to do data validation is the Before Update event of the
form.
 
R

Richard

Hi Bill

Thank for the tip. But if the user chooses to close from the close button,
is there a way to "unclose" the form?

Thanks again
Richard
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Application Exit Event 0
Close form without saving 13
Close Form Event 4
My changes in Access won't save. 8
VBA Restore Window 1
Capture application close event 2
Active Event 2
onClose Event 3

Top