I want to stop CTRL+F4 saving the record as it closes the form

G

Guest

I have a modal form with buttons for save and cancel. The form's close
button is set to No and the navigation buttons are set to No.
This is all done as I want to run various checks on the data before I save
it. In my testing I have found that CTRL+F4 will close the form and try to
save the record. This comes up with a MS Access error message, 'You can't
save this record at this time etc.', which will not be helpful to the users.
I have tried to trap for CTRL+F4 by setting 'Me.KeyPreview = True' in the
Form Load event and looking for the ascii code in the Key Press event on the
form. It appears that the Key Press event doesn't fire. Can someone help me
to find what event fires when CTRL+F4 is pressed so that I can trap it and
cancel the changes neatly.

Thanks,

Paul.
 
S

Scott McDaniel

I have a modal form with buttons for save and cancel. The form's close
button is set to No and the navigation buttons are set to No.
This is all done as I want to run various checks on the data before I save
it. In my testing I have found that CTRL+F4 will close the form and try to
save the record. This comes up with a MS Access error message, 'You can't
save this record at this time etc.', which will not be helpful to the users.
I have tried to trap for CTRL+F4 by setting 'Me.KeyPreview = True' in the
Form Load event and looking for the ascii code in the Key Press event on the
form. It appears that the Key Press event doesn't fire. Can someone help me
to find what event fires when CTRL+F4 is pressed so that I can trap it and
cancel the changes neatly.

Use the BeforeuPdate event to capture the save, and don't worry about capturing the keystrokes. The form's BeforeUpdate
event fires whenver the form tries to save a record ... so just capture it there.
Thanks,

Paul.

Scott McDaniel
scott@takemeout_infotrakker.com
www.infotrakker.com
 
G

Guest

Have you tried using the BeforeUpdate event of the form to do the validation?

In this event using the line

If Validation = False Then
Cancel = True
End If

will stop the exit
 
G

Guest

Thank You very much. Working fine now.

Scott McDaniel said:
Use the BeforeuPdate event to capture the save, and don't worry about capturing the keystrokes. The form's BeforeUpdate
event fires whenver the form tries to save a record ... so just capture it there.


Scott McDaniel
scott@takemeout_infotrakker.com
www.infotrakker.com
 

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

Top