473,473 Members | 1,999 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

How to stop an edit form from saving unwanted changes?

67 New Member
I currently have a form to allow changes to a record in a Table. Sometimes, if the user has entered some changes, but then changes their mind, is there a way that I can allow them to close the form WITHOUT making any changes to the record???
Jan 19 '11 #1
1 2123
Stewart Ross
2,545 Recognized Expert Moderator Specialist
Hi. You can provide a 'Close without saving changes' button on your form which undoes the current entry if changes have been made, on confirmation that abandoning the current record is what the user wants to do. If the button is named cmdAbandon, say, then the sample code below would provide a specific route out for the user:

Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdAbandon_Click()
  2.     Dim strMessage As String
  3.     Dim blChangesMade As Boolean
  4.     blChangesMade = Me.Dirty
  5.     strMessage = "Are you sure you want to "
  6.     If blChangesMade Then
  7.         strMessage = strMessage & "abandon the changes you have made?"
  8.     Else
  9.         strMessage = strMessage & "exit from this form?"
  10.     End If
  11.     If MsgBox(strMessage, vbExclamation + vbYesNo, "Abandon this entry") = vbYes Then
  12.         If blChangesMade Then
  13.             Me.Undo
  14.         End If
  15.         DoCmd.Close
  16.     End If
  17. End Sub
This does not prevent the user from closing the form using the form's top-right close button, which would automatically save any changes made. There are ways round this, but these can be a little more complex to handle, and if you have provided a specific 'abandon' route you should really not need to go for the extra complexity of undoing the update in these circumstances.

-Stewart
Jan 19 '11 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Al | last post by:
hi I have a Datagrid where I click on the id to open another aspx page to edit the selected record. I was able to pass the selected row's id and use it in the second page to pull the record into...
2
by: endran | last post by:
Hi Friends how to stop reopen form which already opened. for example my form code is like this every time when i click opening the form i want to stop that please help M.A.Endran Private...
2
by: Julia Baresch | last post by:
Hi everyone, As some of you may know, we've been having trouble with an unrecognized database format error. Today I installed an unfinished project on the workstation of one of my users. ...
2
by: lorirobn | last post by:
Hi, I have a continuous form which displays all the records on a table. The detail row has a command button which, if pressed, takes the user to another form where that record can be edited. ...
2
by: Jack | last post by:
Hi, I got a edit form in a asp application which allows multiple record edit from the same page. The edit screen works great to a point. I developed this application on my laptop(15"). However,...
2
by: Parasyke | last post by:
Please help.... I have a form that I successfully add records to that I want to copy and turn into a form for editing records from that same table (It is imperitive that it be done this way, rather...
12
by: Birky | last post by:
How can I stop a form from updating the database when a user closes the form? I have a form which is used for referencing, additions, and modifications but every time the form is closed with no...
6
jwagener
by: jwagener | last post by:
Hi, I am building a content menager/news manager and am having trouble with my edit page. I have never embarked on a project like this before and am a bit of noob to php and mysql development....
2
by: Quiver | last post by:
How do you stop a form from maximizing on open. When I close a report, I want "frmMAIN" to open at it's normal non-maximized size. But, it keeps opening fully maximized. Here is my code. ...
1
by: natalie84 | last post by:
Here it goes.... I am using ASP. language: VB I have 2 database as follows.... Database1: User_Details User_ID | User_Name ST-David | David John PUP-Peter | Peter Soh ST-Kelvin | Kelvin Tan ...
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
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.