Results 1 to 10 of 10

Thread: Undo Button

  1. #1
    Join Date
    Sep 2007
    Posts
    148

    Unanswered: Undo Button

    I search the internet and found a form which has an "undo button". The button will only be available if the current record is being edited.

    I modified the code and of course it is not working for me. I edit the record and the button doesn't activated and I click the button anyway, it didn't undo the change. I think it just didn't do anything.

    Note, "Title" is the first field in my table.

    Can anyone tell me what have I done wrong!!!

    Thanks

    *********************************************

    Option Compare Database
    Option Explicit

    ******************************************
    Private Sub Form_Timer()

    Static bFlag As Boolean
    If Me.Dirty Then
    If Not bFlag Then
    Me!cmdUndo.Enabled = True
    bFlag = True
    End If
    Else
    If bFlag Then
    Me!Title.SetFocus
    Me!cmdUndo.Enabled = False
    bFlag = False
    End If
    End If
    End Sub
    ******************************************
    Sub cmdUndo_Click()
    DoCmd.RunCommand acCmdUndo
    End Sub

    *********************************************

    P.S. In the example, under "Private Sub Form_Timer()" it said

    " ' the Timer Interval has been set at 1000, that is, once per second."

    And I don't know what that mean and if I suppose to do something somewhere?

    I also don't know if I need these too!!!!

    Option Compare Database
    Option Explicit



    Thanks
    Last edited by sweetmail; 10-16-07 at 13:40.

  2. #2
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    I'd not use the above code if I were you...

    If you are using bound forms simply issue a
    Code:
    DoCmd.RunCommand acCmdUno
    In fact...
    Linky!
    George
    Home | Blog

  3. #3
    Join Date
    Sep 2007
    Posts
    148
    I think you mean acCmdUndo instead of acCmdUno!!

    ******************************************

    I delete all the code and have

    Private Sub cmdUndo_Click()
    DoCmd.RunCommand acCmdUndo
    End Sub


    It doesn't work. When I edit the form, the Undo button doesn't activate. When I click the Undo button, it doesn't activate. It just sits there!!!


    Any help is greatly appreciated it.

    Thanks

  4. #4
    Join Date
    Sep 2007
    Posts
    148
    I got it working now. Thanks

    I just need to put 1000 in the Time interval in the Form. I use all my old code.

    However, can anyone tell me what does these code do?

    Option Compare Database
    Option Explicit

    Thanks
    Last edited by sweetmail; 10-16-07 at 14:31.

  5. #5
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    Instead of using the timer event - try taking a look at the On Dirty event. It'll be much more efficient and effective
    George
    Home | Blog

  6. #6
    Join Date
    Apr 2003
    Location
    Alabama, USA
    Posts
    154
    Maybe this might be helpful - Form Buttons - Add, Delete, Save, and Undo changes

    Here's some info on what Option Compare Database does, basically how text comparisons are to be handles:
    - ACC: Explanation of "Option Compare Database" Statement
    - Specifying the String-Comparison Setting for a Modul

    'Option Explicit' just forces the code to halt if you have any undeclared variables and is a good way to catch undeclared variable; i.e. you must explicitly declare all variable within a module.
    http://AccessDB.Info

    You live and learn. At any rate, you live. - Douglas Adams

  7. #7
    Join Date
    Sep 2007
    Posts
    148
    Thank you Cosmos75

    I downloaded the file you recommanded but none of the button works. I am running Access 2003 and I don't know if that is the problem.

    Maybe this might be helpful - Form Buttons - Add, Delete, Save, and Undo changes


    I love to see a working example because I want to have the save, delete and undo button for my form.

    I will read the two documents you have provided me.

    Thanks

  8. #8
    Join Date
    Apr 2003
    Location
    Alabama, USA
    Posts
    154
    Quote Originally Posted by sweetmail
    I downloaded the file you recommanded but none of the button works. I am running Access 2003 and I don't know if that is the problem.
    Well, that's embarrassing!


    What exactly isn't working? I just downloaded it and it seems to be working fine. Did you download the Access 2000 version?

    I would recommend opening it and then changing the values for one record;
    e.g. Text 1 to Text 111, and its corresponding number 1 to 111. You should be prompted for each change. And then before being able to click another record, you should be prompted if you want to make those changes permanent.

    You should also be able to undo a changes to a record so long as you haven't used the save button or answered Yes when being promted and asked want to make any changes permanent when attempting to move to another record.

    Let me know what you find and if there are problems with the sample, I'll have to revisit it.
    Quote Originally Posted by sweetmail
    I will read the two documents you have provided me.
    Well, I hope that at least those two links will prove useful.
    http://AccessDB.Info

    You live and learn. At any rate, you live. - Douglas Adams

  9. #9
    Join Date
    Sep 2007
    Posts
    148
    I download the Access 2000 version and I also converted into the 2003 version.

    I try both version, the undo button is not working properly!!! I cannot undo any edit.

    Thanks for your help

  10. #10
    Join Date
    Apr 2003
    Location
    Alabama, USA
    Posts
    154
    Are you getting any prompts (i.e. msgboxes) at all? Any error messages?

    Keep in mind that you cannot 'undo' any changes to a record once you have saved it. Basically, any changes make to individual fields are visible but the record itself is not altered until you move to another record which is why you must undo any changes before moving to another.
    http://AccessDB.Info

    You live and learn. At any rate, you live. - Douglas Adams

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •