Solved

Editing using Forms in MS-Access

Posted on 2012-03-30
6
234 Views
Last Modified: 2012-04-02
I have a form that was previously created in Access that uses one of the tables as a record source to display the data for each record and also and enable editing of the data. The form is fine, except that I would prefer the data for the record not be updated right away if the user types in a new value or modifies one of the existing values. This is because sometimes the user might accidentally enter an incorrect value or mistakenly type over an existing value but the changes to the record are effected right away. What I would like to have instead, is a Save button that will save the changes that were made. If the user does not press the button, then whatever changes that were made will not be saved. What is the best way to go about this?
0
Comment
Question by:geeta_m9
  • 3
  • 2
6 Comments
 
LVL 119

Expert Comment

by:Rey Obrero
ID: 37789722
what about if the user is entering New Record, do they still have to click the Save button?
0
 

Author Comment

by:geeta_m9
ID: 37790133
It doesn't matter, whichever is easier. They will not be entering new records there. The entries will be imported from a spreadsheet using a separate option.
0
 
LVL 20

Expert Comment

by:clarkscott
ID: 37790689
On a "single record" form....

Remove all the 'bound' fields from the CONTROL SOURCE properties of all boxes.
When the user wants to view a record, retrieve the record in code and populate the values in the unbound text boxes on the form.
The user can then change, add, do whatever they want..... but code in the SAVE BUTTON will either locate the record, or create a new record, and populate the recordset from the code.

or

In the Before Update event of the form, add a message box that prompts the user to SAVE or NOT.  If they say NO.... use the sendkeys escape (twice) to reset the record back to original and move on.

Scott C
0
Get up to 2TB FREE CLOUD per backup license!

An exclusive Black Friday offer just for Expert Exchange audience! Buy any of our top-rated backup solutions & get up to 2TB free cloud per system! Perform local & cloud backup in the same step, and restore instantly—anytime, anywhere. Grab this deal now before it disappears!

 

Author Comment

by:geeta_m9
ID: 37791006
Thanks. I might go with the second option, but where could I find a good resource if I had to write the code for it?
0
 
LVL 20

Accepted Solution

by:
clarkscott earned 400 total points
ID: 37791180
Here you go:

In the FORM - before update event.


Private Sub Form_BeforeUpdate(Cancel As Integer)

if msgbox("Save Changes",vbyesno) = vbno then
     cancel = true
     me.undo
end if

end Sub

Scott C
0
 

Author Comment

by:geeta_m9
ID: 37798251
It works like a charm! Thank you!
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Article by: Leon
Software Metering within our group of companies has always been an afterthought until auditing of software and licensing became a pain point. Orchestrator and SCCM metering gave us the answer and it was an exciting process.
No matter the version of Windows you are using, you may have some problems with Windows Search running too slow or possibly not running at all. Before jumping into how you can solve this issue, just know there are many other viable alternative deskt…
The view will learn how to download and install SIMTOOLS and FORMLIST into Excel, how to use SIMTOOLS to generate a Monte Carlo simulation of 30 sales calls, and how to calculate the conditional probability based on the results of the Monte Carlo …
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…

705 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

16 Experts available now in Live!

Get 1:1 Help Now