a Form_BeforeUpdate(Cancel As Integer) question (1 Viewer)

Funkyaccess

Registered User.
Local time
Today, 10:59
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.
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 10:59
Joined
Aug 30, 2003
Messages
36,129
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.
 

Zaeed

Registered Annoyance
Local time
Tomorrow, 03:59
Joined
Dec 12, 2007
Messages
383
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..
 

Julian

Registered User.
Local time
Today, 18:59
Joined
Apr 23, 2009
Messages
20
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:

gemma-the-husky

Super Moderator
Staff member
Local time
Today, 18:59
Joined
Sep 12, 2006
Messages
15,680
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

Top Bottom