By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,446 Members | 3,031 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,446 IT Pros & Developers. It's quick & easy.

Save a record programmatically from a form's module

P: n/a
I know I've asked this before, but the answer elludes me and the message has
long since disappeared from my newsgroup messages. How do you save a record
using vba from a button or as part of an after update event in a form?

dixie
Nov 12 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Preferred approach:
If Me.Dirty Then
Me.Dirty =False
End If

Include error handling to trap the error messages if the save cannot succeed
for some reason (e.g. required field missing, or validation rule not met).

You would not need to do this in Form_AfterUpdate, since the record has just
been saved. If you have any code that dirties the record in
Form_AfterUpdate, move it to Form_BeforeUpdate instead.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"dixie" <di****@dogmail.com> wrote in message
news:Zl***************@nnrp1.ozemail.com.au...
I know I've asked this before, but the answer elludes me and the message has long since disappeared from my newsgroup messages. How do you save a record using vba from a button or as part of an after update event in a form?

Nov 12 '05 #2

P: n/a
If you mean the record displayed on a bound form, in the button click event
the simplest is Me.Dirty = False. An alternative is DoCmd.RunCommand
acCmdSaveRecord.

That will save the record if there have been any changes to the data; if
there haven't been any changes, there's no need to save. On a bound form,
there's no need to save in the AfterUpdate event, because it doesn't fire
until the record has been saved.

If you aren't talking about the current record in a bound form, please
clarify.

Larry Linson
Microsoft Access MVP

"dixie" <di****@dogmail.com> wrote in message
news:Zl***************@nnrp1.ozemail.com.au...
I know I've asked this before, but the answer elludes me and the message has long since disappeared from my newsgroup messages. How do you save a record using vba from a button or as part of an after update event in a form?

dixie

Nov 12 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.