on close event

  • Thread starter Thread starter Richard
  • Start date Start date
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
 
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.
 
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

Back
Top