I have a form with an undo button which works fine...sometimes.
The issue is if the user hasn't clicked out of the text box they have updated before clicking the undo changes button only the changes they have made to that text box are un-done.
My question is when the user clicks the undo chnages button how do I code it so the changes to the whole form are undone even if they haven't clicked out of the last text box they updated.
I have some forms where I can cancel my input. However this works only on the current record. When I implement a subform this does not work anymore. Because access auto saves when focus is set to the subform.
I don't wan't to use unbound forms. What I would like to do is when I press EDIT that a snapshot or something is taken of the current values. So I can set them back.
I can use variables for the main form, but I don't know how to save the values of the records of the subform.
Or does the possibility exist to use transactions?
I just want to be able to undo all changes regardless of the subforms.
I need to program vba to "Undo" only one field on a form, not the entire form. The user enters a number of fields and then tabs to a text field which allows them to enter an 8 digit code. If this code matched one already in the database, I have a message box telling them of the match and offering to either clear the entry or to allow them to go back and edit what they have entered. The 2nd part of this works fine, but I can't figure out how to just clear the text box without clearing the entire form. (the form is bound to a table)
I have tried DoCmd.RunCommand acCmdUndo which clears the entire form.
Me.TextBox.undo does nothing at all.
(a search found several websites that say use Me!TextBox.undo, but that doesn't pass the complier)...
I have a Memo box where the user puts comments and then I have a check box that if check automatically puts a specific phrase on the first line of the Memo box (before any other text currently in the box). What I am trying to do is have it so that if the "check box" is UN-checked it will remove the line that it just added to the Memo box. I have been able to get it to undo everything in the Memo box, but what I really need is for it to just undo the last line of text that was enterd when the user checked the box.
Example:
Memo Box: This is the line that the checkbox just added when the checkbox is set to "True" This is the test data the user has already put in the box... ==================
User now UN-checks the checkbox (I want the Memo box to read.. see below) Thereby deleting the line "This is the line that the checkbox just added when the checkbox is set to "True""
Memo Box: This is the test data the user has already put in the box...
Hi, I have found the answer to most of my problem, thanks to previous posts. I am using the Undo command on a Date field. However it seems that my code is maybe not staying on the event to action the undo.
After it runs the Focus goes to the next field Me.LeaveDays and the value is automatically entered, unless I comment back in the Goto's in which case the value will be zero.
I want to be able to Undo the EndDate (and preferable the StartDate, and Setfocus to StartDate) EndDate will do if not possible.
Don't want to Undo the whole form, although that could be a last resort.
My code is in the before_update event, image posted (ignore faded fields, not visible/needed in final solution) Private Sub EndDate_BeforeUpdate(Cancel As Integer) On Error GoTo Err_EndDate_BeforeUpdate
Dim intLeaveLeftAL As Integer Dim intLeaveLeftSL As Integer Dim intLeaveDays As Integer Dim dtNullDate As Date Dim varNullField As Variant
' Use the WorkingDays function to calc the number of Leave Days ' set LeaveDays and requery the form intLeaveDays = WorkingDays(Me.StartDate, Me.EndDate)
If Me.LCode = "LC41" Then ' Sick Leave
Select Case intLeaveDays Case Is > intLeaveLeftSL MsgBox "Employee does not have enough Leave" & vbCrLf & "to take as Sick Leave.", vbCritical + vbOKOnly + vbDefaultButton1, "Entry in Error" varErrorCondition = True Me.EndDate.Undo GoTo Exit_EndDate_BeforeUpdate Case Else: End Select
ElseIf Me.LCode = "LC11" Or Me.LCode = "LC13c" Then ' Annual or C/Fwd Leave
Select Case intLeaveDays Case Is > intLeaveLeftAL MsgBox "Employee does not have enough Leave" & vbCrLf & "to take as Annual Leave.", vbCritical + vbOKOnly + vbDefaultButton1, "Entry in Error" varErrorCondition = True Me.EndDate.Undo GoTo Exit_EndDate_BeforeUpdate Case Else: End Select End If
I thought "Undo" was only available while in the current record.Here were my steps:
1 - Loaded form that shows 1 record per form page. 2 - Edited a record 3 - Moved to another record with status bar nav arrow 4 - Verified my edit was in the underlying table 5 - Moved back to the original record, again using status bar nav arrow 6 - Clicked my "undo" control and the original data appeared in the form 7 - Moved to another record 8 - Verified my original data was now back in the underlying table
This frame controls an option group. If they are in an existing citation and want to start one for another type, this offers to write a new record in when they try to switch. Problem is, if it DOES write the new record, it seems to be saving the old record, and thus both will end up 56, for example. Access seems to be ignoring/overwriting the Me.frameCitationType.Undo (I don't want to use Me.Undo because they may have made other changes as well).
If the user does not spawn the new citation, it undoes fine. I suspect the problem may be the Filter/FilterOn?
Code: Private Sub frameCitationType_BeforeUpdate(Cancel As Integer) Dim chap As Integer Dim othercit As Variant Dim curRecord As DAO.Recordset Dim curDefend As DAO.Recordset If Me.NewRecord = True And IsNull(Me.CaseNumber) Then MsgBox "Enter the Service Order and Increment first, please.", vbExclamation
Is there a way to code something that will say do Undo All changes. I have a button called Exit without changes…and I would like to be able to undo everything that a user has just done on the form. Thanks.
Is there a way that I can make a button which will undo all the changes being made on a form (on multiple records). I have a continious form with a checkbox after each record and want to restore the 'old values' if necessary.
Thanks.
I know it's possible by record, but the tricky part is to do this on multiple records.
We have an mdb back end on our server with read / write permissions for several approved users. One of them (don't know who yet) has converted the mdb file from 1997 to 2000. Is there a way to undo this? :o (a few have both versions on their machines which is why this was possible to begin to with)
We have had this set up for almost four years now, with no issues might I add but always knew in the back of my mind something like this would happen.
I have a form with a subform, on the mainform there is an undo button but when someone makes changes on the subform the undo button wont run and the error message "The command or action Undo isn't available now". How can i get the mainform to detect that changes have been made on the subform and then if the button is clicked undo the changes.
I would like to be able to check to see if undo is available.
ie. i have a button thats called 'Cancel' When clicked it undo's changed and then closes the form, but if there are aren't any changes to undo it flags up an error saying not available.
I would still like it to close the form even if there are no changes to undo.
So check to see if the undo is available then undo and close if not then just close the form.
Hello All, I am finding this one difficult so felt I should post my issue. I have status field on my form. It is a bound field. A combobox - inactive, active. I wanted the field to do the following when changed If change then msgbox = Please enter reason in activity notes a vbYesCancel If they select it calls the activity notes form - this portion works. If they select cancel I tried making the field do form.field.undo (Me.statusid.undo) - something similar Cancel = True to reset the field to the original state. This fails and says my object is not valid I would be happy to take any suggestions . As always thanks in advance.
I use a listbox and a command button on a form as criteria to open another form.
The click event of my cmdbutton has the following code that runs after selecting a record in the listbox:
If IsNull(Me![NAME]) Then MsgBox "Sorry! No record selected" Exit Sub End If
DoCmd.OpenForm ("myform")
I have now created a menu bar and would now like to remove the command button and place it somewhere that can run when I select the menu to open a specific form.
Basically I need that when I select a menu from my menu bar, the code should verify is a record in the listbox has been selected. If yes, then it will open that form, if not it should run the undo command and not open the form but bring me back to the form on which is placed my listbox (frmEforms).
I have a form that has multiple text boxes. Was trying to add an Undo button that behaves exactly the same as the (Ctrl+Z) or the undo button used in microsoft access, word, excel ..etc. as it only undos one action in a click. When added the undo button i used just a normal button and added a code to it. if i type in different text boxes and press on the undo button it undos everything modified since the form was opened. Is there a way to change that ?
I have two tables Tbl_Referrals and Tbl_CMSData. Both of these tables have an identifier in called ConflictID. I have created a query which selects the records from both tables where the conflict ID is the same.
I have a form running this query. Down one side of the form i have all the details from Tbl_CMSData and on the otherside of the Form i have the corresponding details from Tbl_Referrals. I need the user to be able to update field by field from Tbl_CMSData to TblReferrals. This is done by means of a simple update query for each field. This all works fine.
Problem - I need an undo button for each field. Me.Undo does not work becuase the changes have been made by a query and not on the form.
Is there a way of undoing what the query has updated? Possibly by setting the focus to a Tbl_Referrals and then undoing the changes?
I've a button that position the table on a new record:
DoCmd.GoToRecord , , acNewRec
And I create a button to cancel that action:
Me.Undo
But the code field (autoincrement) continues autoincrementing! Explaning:
1. I click on "Add" button 2. The table's positioned on autoincrement code #1 3. I click on "Cancel" button 4. The register is cancelled, it isn't includded on table 5. I click on "Add" button 6. The table's positioned on autoincrement code #2 and the #1 isn't exists...
I have a form and a linked subform which are linked by Purchase Order Number. When items have been delivered on the purchase order, the user should update the continuous subform with the number of items that have been delivered. This works fine.
The problem I have is using an exit button that does not save any of the changes to either the data in the form or the subform. It doesn't matter if there is a prompt to alert the user that there have been changes made.
I have been messing around with DoCmd.RunCommand acCmdUndo in the on click event of my exit button which kind of works when changes has accidentally been made, but is very unsophisticated - any ideas?!
Hi, Have a main form with subform. Can udo edits on the main form and am trying to do the same for the subform and am having problems. Can someone correct my syntax for me please..........and maybe someday I'll get it!
Here's my code below....thanx.
Private Sub PDEditUndoBut_Click() On Error GoTo Err_PDEditUndoBut_Click
I have a main form (A) with a subform that is another form with a datasheet(A_SUB)
On the form A is an undo button which rewinds any changes that occur to A that I do not wish to commit. However when I make a change to A_SUB the changes are not rewound. I considered implementing an UNDO for A_SUB but this is messy. What would be a better solution?
I am using unbound forms and multiple recordsets to save data into a number of tables. The save procedure is two parts: the first one saves data from a temporary table tblT to tblA. Second part takes the primary key of this new record in tblA and stores it with additional data in tblB.
In case there is an error, this procedure creates all kinds of problems. Usually the errors happen in the second part of the code and by then the data has already been saved in the tblA. On Error, the sub exits. When the user makes changes in the info and retries to save, the sub again tries to save data from the tblT to tblA, but now runs into primary key problems as the data already exists! (the reason for this is because the primary key field for tblA is filled with an autonumber generated by tblT).
Ideally, on error, the sub should delete the last record (or two or three, as the case may be) from tblA so that they can be re-stored by the sub on resumption. I cannot get either an SQL statement or a recordset to identify exactly these records to delete them. All help is highly appreciated! Also, any suggestions towards alternative methods of achieving this are most welcome!
Hi everyone! Well, I goofed... I was trying to figure out how cause access to launch a switchboard I made and NOT launch the regular shortcut bars or database window. Well, fortunately the help file told me I could change that in tools...startup options...
I found it, and it worked great, except I can't get back into my regular shortcut menu features, including the startup options themselves to reverse it. I did figure out I could reclaim the database window by pushing f11, but sadly have been unable to figure out how to get to my shortcut menus and back into startup options. Anyone know how I can get back in?
Next time I'll have to make a copy before doing that...
Could someone look at my code and tell me why my “Me.TargetDate.Undo” won’t work?
First, let me say that the TargetDate field has an On-Click event that calls a module written by Allen Browne), which is shown below and works great.
=CalendarFor([TargetDate],"Select a date from the calendar ")
What happens is that the Me.TargetDate.Undo event always keeps the date selected in the calendar.
Based on something I read from Rual Guy on another issue, I’ve used the TargetDate_LostFocus routine to check for some additional data entry errors. I’ve tried moving the code in “Private Sub TargetDate_Exit(Cancel As Integer)” to the LostFocus, but it doesn’t make any difference to the Undo. I’ve also tried “I’ve tried “Private Sub TargetDate_Change(),Me.Undo…” but that doesn’t work either. :confused:
Private Sub TargetDate_Enter()
If Not IsNull(Me.TargetDate) Then OldTarget = Me.TargetDate End If
End Sub
Private Sub TargetDate_Exit(Cancel As Integer)
If Not IsNull(Me.TargetDate) Then If DateDiff("d", Me.DateOpened, Me.TargetDate) < 0 Then MsgBox "You have selected a date that is before…bla bla" Me.TargetDate.Undo Me.TargetDate.SetFocus ElseIf DateDiff("d", Date, Me.TargetDate) < 0 Then MsgBox "You have selected a date that is prior to today's date…bla bla" Me.TargetDate.Undo Me.TargetDate.SetFocus ElseIf Weekday(Me.TargetDate) = 1 Or Weekday(Me.TargetDate) = 7 Then MsgBox "You have selected a date that falls on a weekend..bla bla" Me.TargetDate.Undo Me.TargetDate.SetFocus End If End If End Sub
Private Sub TargetDate_LostFocus() If Me.TargetDate > OldTarget And Me.cboAssignToID <> OldAssignee Then MsgBox "The target date can only be changed if …bla bla" Me.TargetDate.Undo Me.TargetDate.SetFocus End If End Sub