saving a record

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
 
A

Allen Browne

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.
 
P

Paul

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)?
 
A

Allen Browne

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.)
 
P

Paul

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.)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top