How does acCmdSaveRecord work, how does it know which values to save to a table

JoshRountree

New member
Local time
Today, 18:23
Joined
Dec 13, 2006
Messages
5
I can't find anywhere that explains in detail what acCmdSaveRecord does. How does it know which values to save in the table/row and how they match up? Any help is greatly appreciated.
 
Does the fact that it works with a 'bound' table (and bound controls) help?

:)
ken
 
Basically all this does is to force the current record in the form to save all its values to the underlaying table.

When you make a new record, the values shown in the controls on the form are not yet saved to the table until the record is saved. Saving automatically occurs when you shift the focus to another record, or when the form closes, but there are times when it is useful to force the current record to save so that you can then use domain aggregate functions (Dlookup etc) and have the current record's values included in the results.
 
Does the fact that it works with a 'bound' table (and bound controls) help?

:)
ken

I've done quite a bit of programming and have been given a project to take over and maintain. I felt confident there was some type of binding but just don't see it. Is it the "Bound Column" in the "Data" tab from the properties?
 
The form will be bound to the table or query with the 'record source' property and the controls bound to the table fields with the 'control source' property

:)
ken
 
The form will be bound to the table or query with the 'record source' property and the controls bound to the table fields with the 'control source' property

:)
ken


Ahhhh....makes perfect sense now. Thank You!
 
One of the times Craig alluded to would be if you're using DoCmd.Close to close a form.

Either

acCmdSaveRecord

or

If Me.Dirty Then Me.Dirty = False

which also forces a save, should be used before using

DoCmd.Close

to close a form because of a quirk in Access. When DoCmd.Close is used, Access closes the form regardless of whether a validation rule/required field rule has been violated! If one of these rules has been violated, Access will simply dump the record, close the form, and not tell the user that the record has been dumped!

If Me.Dirty Then Me.Dirty = False or acCmdSaveRecord forces Access to attempt to save the record, and if a violation has occurred, will throw up a warning message allowing correction to be made before closing the form.

Linq
 

Users who are viewing this thread

Back
Top Bottom