Cancel BeforeUpdate event

AccessFreak

Registered User.
Local time
Today, 22:41
Joined
Feb 19, 2009
Messages
69
Hello everyone,

When I click the save button on my form, the BeforeUpdate event must be cancelled. How can I do that?
 
You will not save if you cancel the event. How about describing the problem a little more?
 
Look within the btn_Save.OnClick the following happens:

The user will be asked to save the record and to open an new clean record.

The form.BeforeUpdate comes directly after I click on the save button. I want to prevent this by canceling the BeforeUpdate event when I click on the save button.

form.BeforeUpdate does the same as btn_Save, but only occurs when trying to exit the form. That does work correctly but when clicked on the save button the BeforeUpdate doesn't have to run.
 
The FORM BeforeUpdate *must* run in order to save the record.
 
Yeah I know but BeforeUpdate needs to occur only when I quit the form. When clicking the save button I'll need to stay in the form, the BeforeUpdate have to be cancelled when clicking the save button.
 
I don't think you understand. When saving the current record by *any* means, the FORM BeforeUpdate event *must* run or the record is not saved. What is wrong with that event running? Do you have some code in there that you don't want to run if the user presses the "Save" button?
 
what RG is saying is that when a record is saved, ie written to disc (table) the event that is the beforeupdate event takes place. Indeed so does the afterupdate event, immediately after a successful update

note that a failed update will cause an error event


Now, there are a number of methods of making the save happen

eg
click a button with code as you are doing

but also
use records save from the menu options
just move to a new/different record
close the form
run code that just says if me.dirty then me.dirty =false
click the pencil in the record selector
etc etc

---------
now the purpose of the beforeupdate event handler is to let you do something BEFORE that save takes place - which is normally a validation test. if the validation fails then you can cencel the save, BY cancelling the beforeupdate - in which case you also get no afterupdate event

BUT the important thing is, even if you dont have an event handler, the event still takes place.

now how you manipulate your code is up to you ... but thats what happens. the difficulty (if thats what you are trying to do) is to force a user to save the record just by clicking a certain button - as he has so many other ways to try and save the record, accidentally or on purpose
 
Last edited:
I don't think you understand. When saving the current record by *any* means, the FORM BeforeUpdate event *must* run or the record is not saved. What is wrong with that event running? Do you have some code in there that you don't want to run if the user presses the "Save" button?

Kind of makes me think of Abbott and Costello's "Who's on First?" routine... :)
 

Users who are viewing this thread

Back
Top Bottom