Solved

Editing using Forms in MS-Access

Posted on 2012-03-30
6
235 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
Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

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.
In this article we discuss how to recover the missing Outlook 2011 for Mac data like Emails and Contacts manually.
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
The viewer will learn how to simulate a series of coin tosses with the rand() function and learn how to make these “tosses” depend on a predetermined probability. Flipping Coins in Excel: Enter =RAND() into cell A2: Recalculate the random variable…

910 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

21 Experts available now in Live!

Get 1:1 Help Now