Saving based on clickable event only

gellerche

Registered User.
Local time
Today, 17:01
Joined
Jun 19, 2001
Messages
73
I have a form with some controls that are bound to the database, a Save button, and a subform. If the user makes any changes to the controls on the form, I don't want them to be able to save those changes without clicking on the Save button. Since the controls are bound, I have a BeforeUpdate event called by my Save button to evaluate what's on the form.

The problem is that if the user clicks on the subform, the BeforeUpdate event runs, and I only want updates by clicking the Save button. I tried:

Private Sub Form_BeforeUpdate(Cancel As Integer)
' If the user has clicked on one of the subforms (ie. the form loses focus),
' then don't update. Only update if the user's clicked on the Save button.
If Form.LostFocus Then
DoCmd.CancelEvent
Else
(Code to evaluate what's on the form)
End If

, but the compiler won't let me use Form.LostFocus. Does anyone have any ideas, either with what's wrong with this code, or other ideas of their own?

Thanks,

Steve Geller
 
Thanks for the information. The difference between your setup and mine is that I have to deal with the subforms. I checked, and part of the Access environment requires that when you click on a subform, the BeforeUpdate event for the form is run. I can't stop it, but I'm looking for a solution where the code I've added to the BeforeUpdate event is only run when the Save button is clicked, not when the event is run by default after clicking on the subform.

I'd appreciate any help anyone can provide,

Steve Geller
 

Users who are viewing this thread

Back
Top Bottom