Solved

MS Access - Update record without closing Form

Posted on 2011-02-22
11
485 Views
Last Modified: 2012-06-27
My question seems basic but I've always let the form save changes to the current record by closing the form which is bound to a table.  Now I've been asked to save the changes on a button click that does not close the form.  Changes need to be saved along the way instead of waiting till the very end when the user is done with the form.

Is there an easier way than itemizing each field equal to the value on the form?  I know I can execute an SQL command UPDATE table SET..... or do a DAO openrecordset SELECT then set each field.....

But there are 27 fields on my form that may have been changed.
Thanks!
Helen
0
Comment
Question by:greenprg
  • 6
  • 3
  • 2
11 Comments
 
LVL 75

Accepted Solution

by:
DatabaseMX (Joe Anderson - Access MVP) earned 500 total points
ID: 34958652
You can easily do this with a button on the form, with one line of code in the button Click event.

Private Sub btnSave_Click()
    Me.Dirty = False  ' save the record
End Sub

mx
0
 
LVL 19

Expert Comment

by:MINDSUPERB
ID: 34958655
Requery the form to reflect the changes of data would be a solution.

Me.requery

Sincerely,
Ed
0
 
LVL 75
ID: 34958659
Note that as soon as any Bound control on the Form is edited, the Form becomes 'Dirty'.  At this point ... if the Save button is clicked, the current changes will be Saved.  Continue to make edits on the same record, and Save again ... and so on.

mx
0
 
LVL 75
ID: 34958669
Ed ... that is not really the best practice just to save a Record.  You Requery when you want to see changes made by other users on the same recordset.  While Requerying will save the record ... it is completely unnecessary.

mx
0
 

Author Closing Comment

by:greenprg
ID: 34958700
Perfect.  I knew there must be a simple command to do this.  Thanks for the explanation.  That really helps too.

Helen
0
Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

 
LVL 75
ID: 34958710
You are welcome.

Are you on the West Coast ?

mx
0
 
LVL 19

Expert Comment

by:MINDSUPERB
ID: 34958711

@mx

I might missed the question. Thanks for the input.

Ed
0
 

Author Comment

by:greenprg
ID: 34958727
Yes.  I can be quite the night owl but I seem to get the most done after my kids are all in bed.  Thanks for the quick response.  I was afraid I was going to need to wait until morning to finish this up.
Helen
0
 
LVL 75
ID: 34958741
West coast where ... just curious.  LA area here.
" I was afraid I was going to need to wait until morning to finish this up."
nah ... 24x7x365 ... or so it seems :-)

mx
0
 

Author Comment

by:greenprg
ID: 34958756
Orange county.  Office is in Gardena so lucky me, I get to work from home and work whenever I want to.  
Helen
0
 
LVL 75
ID: 34958804
The OC ... really.  Small world ... How bout that ... I work for the power company that supplies your power :-)
Gardena ... nice you don't have to drive there every day ... 405 not pretty!
The IE (barely) ... Rancho Cucamonga ... just up the 57 to the 10 .

Time to zzzz out now ...

catch up with you later ...

===
0

Featured Post

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
ms access 2013, running .mdb 2 32
Newbie needs help printing from a form. 10 21
Create Form using Wizard 14 39
Conditional lock of one field in  datasheet 9 22
Regardless of which version on MS Access you are using, one of the harder data-entry forms to create is one where most data from previous entries needs to be appended to new records, especially when there are numerous fields and records involved.  W…
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now