473,569 Members | 2,836 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Cancel command won't undo all changes made to a form listing multiple records

105 New Member
Hello all,

i have a continuous form that displays about 1000 records and opens when I click a button. When the form opens, the user has the option of checking a checkbox that is located beside each record. The checkbox is labeled "Move" (for moving multiple records at a time to another year). Of course, the checkbox is set as a control "moveRecord " on a table that the query is pulling from. So if the user checks one record, then clicks to another record and checks it as well, the first record is automatically saved. If the user decides to check 10 or 20 records, then decides, "OOPS, i may have made some mistakes, i want to cancel!"

i run into a problem....

I have a button on the form that says "cancel." However, if the user clicks that button, the only record that cancels is the last checkbox that was checked. I want all of the checkboxes to disappear when the user opens up the same form again. As it stands right now, the 19 or so other checkboxes still remain as saved into the table.

Please help! Thank you in advance!

I've tried multiple things even the ON DIRTY execute...here' s what I have now

Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdCancel_Click()
  2. On Error GoTo errHandle
  3. Dim intProcced As Integer
  4.  
  5. 'Warn the user that any information entered will be lost, then if the user responds that it is
  6. 'ok, erase the record and close the form
  7.  
  8. intProcced = MsgBox("Warning: Any changes made or any information entered will not be saved.", vbOKCancel, "Warning")
  9.     If intProcced = 2 Then
  10.         Exit Sub
  11.     End If
  12.  
  13. DoCmd.DoMenuItem acFormBar, acEditMenu, acUndo, , acMenuVer1X
  14.  
  15. DoCmd.Close
  16.  
  17. Exit Sub
  18.  
  19. errHandle:
  20. If Err.Number = 2046 Then
  21.     DoCmd.Close
  22.     Exit Sub
  23. Else
  24.     'Print the error message and send an email to Administrator
  25.     SendErrorMsg "cmdCancel_Click on frmEnterNewFeeder", Err.Number, Err.Description
  26.     MsgBox Err.Description
  27. End If
  28. Exit Sub
  29.  
  30. End Sub
Jan 11 '08 #1
8 4767
Rabbit
12,516 Recognized Expert Moderator MVP
Please do not double post your questions, your other thread will be deleted.
Jan 11 '08 #2
Rabbit
12,516 Recognized Expert Moderator MVP
Once you change records, it is automatically saved and the changes are committed and can not be undone. You have two options. One is to not use a dynaset and save the entire recordset's changes when needed. This I do not recommend, too many complications. The second is to run an update query that sets all the checkboxes to false if they click cancel.
Jan 11 '08 #3
jmarcrum
105 New Member
Please do not double post your questions, your other thread will be deleted.
It's not a double post, read it all the way through before making comments.
Jan 14 '08 #4
jmarcrum
105 New Member
Hey thanks for your tip Rabbit...

I modified my code to look like this....

Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdCancel_Click()
  2. On Error GoTo errHandle
  3.  
  4. Dim intProcced As Integer
  5.  
  6. 'Warn the user that any information entered will be lost, then if the user responds that it is
  7. 'ok, erase the record and close the form
  8.  
  9. intProcced = MsgBox("Warning: Any changes made or any information entered will not be saved.", vbOKCancel, "Warning")
  10.     If intProcced = 2 Then
  11.         Exit Sub
  12.     End If
  13.  
  14. If Me.Dirty = True Then
  15.     DoCmd.SetWarnings False
  16.     DoCmd.OpenQuery "qryMoveFeedersFalse"
  17.     DoCmd.SetWarnings True
  18.     DoCmd.Close
  19.     Exit Sub
  20. Else
  21.     DoCmd.SetWarnings False
  22.     DoCmd.OpenQuery "qryMoveFeedersFalse"
  23.     DoCmd.SetWarnings True
  24.     DoCmd.Close
  25.     Exit Sub
  26. End If
  27.  
  28. errHandle:
  29. If Err.Number = 2046 Then
  30.     DoCmd.Close
  31.     Exit Sub
  32. Else
  33.     'Print the error message and send an email to Administrator
  34.     SendErrorMsg "cmdCancel_Click on frmEnterNewFeeder", Err.Number, Err.Description
  35.     MsgBox Err.Description
  36. End If
  37.  
  38. Exit Sub
  39.  
  40. End Sub
Jan 14 '08 #5
Rabbit
12,516 Recognized Expert Moderator MVP
It's not a double post, read it all the way through before making comments.
The only difference I saw was you figured out that once you change records, it is automatically saved and the changes are committed and can not be undone.
Jan 14 '08 #6
Rabbit
12,516 Recognized Expert Moderator MVP
This part is redundant. There's no need to check for Dirty.
Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdCancel_Click()
  2. If Me.Dirty = True Then
  3. DoCmd.SetWarnings False
  4. DoCmd.OpenQuery "qryMoveFeedersFalse"
  5. DoCmd.SetWarnings True
  6. DoCmd.Close
  7. Exit Sub
  8. Else
  9. DoCmd.SetWarnings False
  10. DoCmd.OpenQuery "qryMoveFeedersFalse"
  11. DoCmd.SetWarnings True
  12. DoCmd.Close
  13. Exit Sub
  14. End If
  15.  
Jan 14 '08 #7
jmarcrum
105 New Member
This part is redundant. There's no need to check for Dirty.
Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdCancel_Click()
  2. If Me.Dirty = True Then
  3. DoCmd.SetWarnings False
  4. DoCmd.OpenQuery "qryMoveFeedersFalse"
  5. DoCmd.SetWarnings True
  6. DoCmd.Close
  7. Exit Sub
  8. Else
  9. DoCmd.SetWarnings False
  10. DoCmd.OpenQuery "qryMoveFeedersFalse"
  11. DoCmd.SetWarnings True
  12. DoCmd.Close
  13. Exit Sub
  14. End If
  15.  
What is the person opens the form, makes NO changes and then clicks cancel.
Jan 14 '08 #8
Rabbit
12,516 Recognized Expert Moderator MVP
What is the person opens the form, makes NO changes and then clicks cancel.
Well, the thing is that the query runs no matter what happens. If they make no changes and click cancel, it unchecks all the boxes. If they make a change and click cancel, it unchecks all the boxes. So either way, it unchecks all the boxes.
Jan 14 '08 #9

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

Similar topics

1
519
by: Corrine | last post by:
Is there a way to cancel a change in an option group? The option group still changes to the option clicked on when clicking on the NO button with the following code in the BeforeUpdate event of the option group. If MsgBox("Change?", vbYesNo) = vbNo Then Cancel = True Me!MyOptionGroupName.Undo End If I also tried reversing the Cancel and...
4
1818
by: Deano | last post by:
Alot of my forms are bound. I would like to offer a Cancel option so that they can make as many changes as they like and still Cancel out without making any changes. I have one idea of how to do this for new records; tag each record with a boolean value. On clicking OK, these are all set to True and the form closes. If they Cancel the...
6
2129
by: allyn44 | last post by:
HI--what I am trying to do is 2 things: 1. Open a form in either data entry mode or edit mode depending on what task the user is performing 2. Cancel events tied to fields on the form if I am in edit mode. The reason I want to do this is becasue when entering a new record the form is entered in data entry mode and I have lots of stuff...
6
8230
by: Raji16 | last post by:
Hi, I am a new member. i am designing a simple judicial database system. however after creating tables i am a bit confused on setting the relationships between tables :confused: here is the link of a snapshot of my table design and i wud highly appreciate if anyone cud help me on building the table relationships. Link:...
1
2798
by: Richard | last post by:
A shipment of material is received. The shipment contains several items. Each item is assigned an internal tracking number for auditing purposes and further processed. The tracking number is mandatory, unique and non-zero, but _cannot_ be obtained or assigned automatically by Access (due to business rules ). Table A is the receive table...
4
7821
by: martin | last post by:
Hello, Is there a way to make a kind of "cancel" button on a form? Suppose you accidently changed or overwrote some data in a form, then I'd like to leave this form at once and cancel any change made in this form. Hopefully someone has a clue for me. thanks a lot!
2
11855
by: Matuag | last post by:
Hi All, I want to create following command buttons on a Form which users can edit. Save ( Save Changes made) Cancel ( Undo data changes) Exit ( Close form) I am using Macros for each of these commands and they work perfect.
1
2747
by: inadsad | last post by:
Greetings Group: I got a form with multiple controls that are bound to a dataset, with two buttons & next/previous. Simply, add button adds a new record and cancel button undo changes. On add click event button: Me.BindingContext(ds1.Tables("MyTable")).EndCurrentEdit() Me.BindingContext(ds1.Tables("MyTable ")).AddNew() On Cancel
5
9855
by: jmarcrum | last post by:
Hey everybody! I've created 2 buttons that I've placed on all my forms: a Save button & a Cancel button. The cancel button I have a question about. I used the wizard to create the button and I selected the Record Operations/Undo Record option. I edited the vba code to have the button also close the form after it undoes any changes. ...
0
7695
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7612
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8119
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7668
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7964
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6281
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
3653
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3637
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2111
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 we have to send another system

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.