Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 965
  • Last Modified:

MS Access - Update record without closing Form

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
greenprg
Asked:
greenprg
  • 6
  • 3
  • 2
1 Solution
 
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database ArchitectCommented:
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
 
MINDSUPERBCommented:
Requery the form to reflect the changes of data would be a solution.

Me.requery

Sincerely,
Ed
0
 
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database ArchitectCommented:
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
What Kind of Coding Program is Right for You?

There are many ways to learn to code these days. From coding bootcamps like Flatiron School to online courses to totally free beginner resources. The best way to learn to code depends on many factors, but the most important one is you. See what course is best for you.

 
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database ArchitectCommented:
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
 
greenprgAuthor Commented:
Perfect.  I knew there must be a simple command to do this.  Thanks for the explanation.  That really helps too.

Helen
0
 
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database ArchitectCommented:
You are welcome.

Are you on the West Coast ?

mx
0
 
MINDSUPERBCommented:

@mx

I might missed the question. Thanks for the input.

Ed
0
 
greenprgAuthor Commented:
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
 
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database ArchitectCommented:
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
 
greenprgAuthor Commented:
Orange county.  Office is in Gardena so lucky me, I get to work from home and work whenever I want to.  
Helen
0
 
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database ArchitectCommented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Easily Design & Build Your Next Website

Squarespace’s all-in-one platform gives you everything you need to express yourself creatively online, whether it is with a domain, website, or online store. Get started with your free trial today, and when ready, take 10% off your first purchase with offer code 'EXPERTS'.

  • 6
  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now