saving a record

  • Thread starter Thread starter Paul
  • Start date Start date
P

Paul

I'm aware of two ways to save a record when you want to force a save with
VBA:

1. If Me.Dirty Then DoCmd.RunCommand acCmdSaveRecord

and

2. If Me.Dirty Then Me.Dirty = False

Are they both equivalent, or is one better than the other?

Thanks in advance,

Paul
 
RunCommand acCmdSaveRecord saves the record in the active form (whichever
that is.)

Me.Dirty = False is explicit about which form's record to save, so it's more
reliable if multiple forms happen to be open.
 
Thanks, Allen. One last question:
RunCommand acCmdSaveRecord saves the record in the active form (whichever
that is.)

What if the active form is a subform? Does it save only the record in that
form, or does it also save the record in the main form (and other subforms)?
 
Yes. If the subform is the active control on the main form, it will work.
(Note that if you put the command button on the main form, when you click
the button, it becomes the active control and so the code tries to save the
main form.)
 
Ok, that explains it.

Thanks



Allen Browne said:
Yes. If the subform is the active control on the main form, it will work.
(Note that if you put the command button on the main form, when you click
the button, it becomes the active control and so the code tries to save
the main form.)
 
Back
Top