473,387 Members | 1,606 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Save a record programmatically from a form's module

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
2 12921
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Jason Charalambides | last post by:
Is there a way I can import a given value to a variable from the main form to a module? I wanted to have some routines that are repeated set in a module subroutine. However, the value of a...
1
by: Mustafa | last post by:
dear sir In my vb.net window application i have the MDI form MainMDI and child form form1 adn module as MainModule In my MainMDI Parent form i have one toolbar i.e. tbraction. I am trying to show...
9
by: David Allison | last post by:
cmdButton to Print 3 copies of record in Form view ? cmdButton will print 1 but I need 3 copies of the one Form record. -- Dave Allison
2
by: Douglas Buchanan | last post by:
This is a mystery! Why does the boolean value of a record change without my input. What follows describes the situation and the behavior. Table1: Field1: Text Field2: Yes/No Form1 has two...
1
by: joye | last post by:
Hi, I know how the show a MessageBox in Form.h module by using VC.NET. But I don't know how to show the MessageBox at another class such as task.cpp which called by the Form.h; my question is...
1
by: mgoold2002 | last post by:
Here is the offending excerpt from my code. I just began trying to port some vb code I'd written into my first .NET app. Public Class bannergenerator 'THIS IS AN ORDINARY WINDOWS FORM Inherits...
8
by: glamster7 | last post by:
Ok folks its Friday & I'm feeling a bit thick (also not very well). I have a form Salonmanagerdetail wich allows the user to enter the following details Stylist_Id,Stylist_Name,Group_Name &...
1
by: JOHN C DEVONSHIRE | last post by:
I am creating a new form(s) in MsAcess while it is open by more then one users I have no trouble '------------------------------------------------------------ ' Module :...
1
kirubagari
by: kirubagari | last post by:
Dear expert, i had written the code in my form Public Function HoldType(ByRef sType As String) As String If bOkClicked Then sType = "Rehold " End If
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.