Save The Current Form

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I know it will be devastatingly obvious but can someone explain what I need
to put in the On Click property of a Command Button to have it save the form
currently open?

Thanks
 
Save the form, or save the record being entered? Is your user modifying the
design of the form?

If you want to save the record, I would recommend not using a button at all.
Pressing PAGE DOWN will save it. Moving to a previous record will save it.
Closing the form will save it. Moving to a new record (>*) will save it.

Rarely a need for a button since Access saves the records naturally.
 
Oops. Forgot to answer your question though...

If you do decide to save it, use the following...


If Me.Dirty Then 'Save any edits.

Me.Dirty = False

End If
 
Rick said:
Oops. Forgot to answer your question though...

If you do decide to save it, use the following...


If Me.Dirty Then 'Save any edits.

Me.Dirty = False

Instead of trying to change the value of Me.Dirty, I think you'd be
better off using

RunCommand acCmdSaveRecord

at this point to save the record. See "RunCommand Method" in Access
Help for more information.


-- Vincent Johns <[email protected]>
Please feel free to quote anything I say here.
 
Vincent Johns said:
Instead of trying to change the value of Me.Dirty, I think you'd be better
off using

RunCommand acCmdSaveRecord

at this point to save the record. See "RunCommand Method" in Access Help
for more information.

Why do you think that's better? Setting the Dirty property back to False
works just fine.
 
Douglas said:
Why do you think that's better? Setting the Dirty property back to False
works just fine.

That may be always true, or it may just incidentally be true. I wasn't
able to find any documentation that guarantees it to work that way, and
I *was* able to find documentation that claims (or at least suggests)
that the "RunCommand" will save it, so my suggestion was on the basis of
slightly stronger claims on Microsoft's part. I also found other
documented ways to save the record, but "RunCommand" seemed pretty
straightforward. Perhaps I didn't look in the right place for
"Me.Dirty". Or it may be that Access 2003 guarantees that "Me.Dirty =
False" will save the record and Access 2000 doesn't; I was looking in
Access 2000 and couldn't find it there.

Of course, even with documented behavior, Microsoft's software license,
as I recall, doesn't really guarantee anything at all; we kind of have
to depend on Microsoft's good will and expertise. Keeping that in mind,
if some feature really is undocumented (as I said, I may have missed
something), then that behavior may vanish without warning in a future
version of Access, and any code using it will fail for no obvious reason.

-- Vincent Johns <[email protected]>
Please feel free to quote anything I say here.
 
Back
Top