Saving Records

cable

Access For My Sins
Local time
Today, 13:19
Joined
Mar 11, 2002
Messages
226
I'm trying to work out a save routine that works however the user uses the form.

I started with a simple button (and some extra validation code) but thats no good if the user hits the exit button or the 'x'

So then I started using the form_beforeupdate event which was good because it seem to be called just before a save so I could do validation and allow undo.

But now the user still wants a Save button, and the usual docmd.domenu etc etc doesn't fire the before update event, manual calling the before update doesn't works unless they want to undo.

So what other options are there? Apart from duplicating the code in the button and the beforeupdate events.
 
Curious...

Hi Cable

What are you actually trying to save? The data? - it's not necessary. Does the user have the ability to edit the form in design view? Is this what you want to save?
 
yep the data on the form...

unfortunatly its nessacery because of some extra code that needs to be run before the save, some of it validation some of updating recordsets else where.

plus the users are pretty stupid, need a save button and a confirmation and the ability to undo their mistakes.
 
Do you want the save button to perform the same validation rules etc as the before_Update code etc?

I would keep all your validation code in a separate subroutine
eg
Function fnValidateForm(frm as Form) as Boolean
Validation Code Goes Here - if form is not validated then set fnValidate valueto False
end function

Then on beforeUpdate
If fnValidateForm(me) = false then cancel = true

on click of save button
if fnValidateForm(me) = false then
me.undo
end if

This is a stripped down version of how you may implement it. Does this help?
 
it helps...and brings within 10% of the goal:)

the last problem is also have code that needs executing after a succesful save...but that might be easier to do...depending on the event order.

after before update what comes next? Is it after update?
If it is then I could put the code there...but not if current is fired first.
 
Try putting your validation and processing code in the OnClose property. This works no matter what method of closing is used, short of switching off the PC.

Dave E
 

Users who are viewing this thread

Back
Top Bottom