473,434 Members | 1,820 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,434 software developers and data experts.

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

105 100+
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 4742
Rabbit
12,516 Expert Mod 8TB
Please do not double post your questions, your other thread will be deleted.
Jan 11 '08 #2
Rabbit
12,516 Expert Mod 8TB
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 100+
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 100+
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 Expert Mod 8TB
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 Expert Mod 8TB
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 100+
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 Expert Mod 8TB
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
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...
4
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...
6
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...
6
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...
1
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...
4
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...
2
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...
1
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...
5
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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...
1
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...
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...

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.