a Form_BeforeUpdate(Cancel As Integer) question

Funkyaccess

Registered User.
Local time
Today, 05:57
Joined
Oct 8, 2009
Messages
69
Is there a way of finding out what objected called this update function (Form_BeforeUpdate(Cancel As Integer)).

Like navigation button or a "save" button on the form. I have some validations that I want to run when the user saves but it must not run when the user trys to exit the form i.e close the form or the database or any other way.
 
To my knowledge there's no way to tell. One way of handling this kind of thing is a form level Boolean variable. Set it to false when the form opens, true when the user clicks your save button. Testing that value will determine whether they clicked on the save button or not.
 
I usually handle this by setting a global flag varialbe.. Call it something like whichButton. Then for your button, in its onclick action, set the flag to a number corisponding to the button being used..
Then in your BeforeUpdate, just have a switch statement that handles the various possible flag values..
 
It is called when navigating from a form or record on a form which has new data or the data has changed. I am not aware of determining the calling event.

However, this should make the save only occur after the save button is pressed and ignore changes if the save button is not pressed:

Create a save toggle button called toggle1.

Private Sub Form_BeforeUpdate(Cancel As Integer)
If Me.Toggle1.value = True Then
Else
Me.Undo
End If
Me.Toggle1.value = False
End Sub

Private Sub Toggle1_Click()
Me.Refresh
End Sub

Is this what you want?
 
Last edited:
if you could tell, surely it would change access into a procedural language, rather than an event driven one

its just that the record needs saving, so this event fires - or is this too simplistic?
 

Users who are viewing this thread

Back
Top Bottom