Results 1 to 5 of 5
  1. #1
    Join Date
    Sep 2007
    Posts
    148

    Unanswered: Undo record button

    I used the form Tool box to put an "Undo" buttom in the form.

    When I click the Undo buttom, it actually delete the record and that means, I last ONE record number.

    My primary key is "autonumber". This is my code:

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

    Private Sub cmdUndoRecord_Click()

    On Error GoTo Exit_cmdUndoRecord_Click

    'Exit sub if user cancels UNDO

    If MsgBox("Are you sure you want to undo all your changes to the currect record?", _
    vbYesNo, "cmdUndoRecord_Click()") = vbNo Then Exit Sub
    End if

    DoCmd.DoMenuItem acFormBar, acEditMenu, acUndo, , acMenuVer70

    'Go back to the last record

    DoCmd.GoToRecord , , acLast



    Exit_cmdUndoRecord_Click:


    End Sub

    ********************************************
    Say I open a new record and the record number is 102, say half way throught entering the data (through a form), I decide not to create the record after all. I click the UNDO button, according to my code, it will go back to record 101. However, when I try to create a new record later, the record number will be 103 insteadt of 102. Is there anyway I can make the system to use 102 instead of 103.

    Since several users can accessing the Backend tables on the server from their Front-End Form running on their desktop at the same time, the record 103 maybe being used a second after I have created record 102. Is it possible to still have access using the missing 102 number (for examplt ) at its' earliest opportunity.

    Thanks

  2. #2
    Join Date
    Nov 2007
    Location
    Adelaide, South Australia
    Posts
    4,049
    There HAS to be a rubberstamp answer to this...

    In short,... just let it go. The unique ID is still unique and the missing number won't be noticed.

    If you absolutely MUST have your IDs be sequential, you can't use Autonumber... you'd have to use a Number and set it with VBA just before the record is inserted.
    Owner and Manager of
    CypherBYTE, Microsoft Access Development Specialists.
    Microsoft Access MCP.
    And all around nice guy!


    "Heck it's something understood by accountants ... so it can't be 'that' difficult..." -- Healdem
    "...teach a man to code and he'll be frustrated for life! " -- georgev

  3. #3
    Join Date
    Sep 2007
    Posts
    148
    I was kind of sensing that autonumber may not be what I want after all. Any example for using a Number and set it with VBA just before the record is inserted. My IDs being sequential is kind of important to my big boss (my boss's boss)

    Thank you for the reply StarTrekker.

    By the way, my application is coming along very well, thanks for your help StarTrekker and many others in this forum.

  4. #4
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740
    i posted one way to do sequential numbers in the codebank.

    izy
    currently using SS 2008R2

  5. #5
    Join Date
    Nov 2007
    Location
    Adelaide, South Australia
    Posts
    4,049
    You're most welcome sweetmail

    Assuming your ID is CustomerID that's a Number data type...

    In the form's Before Insert event procedure:

    Me.CustomerID = DMax("CustomerID", "CUSTOMER") + 1

    That kind of thing
    Owner and Manager of
    CypherBYTE, Microsoft Access Development Specialists.
    Microsoft Access MCP.
    And all around nice guy!


    "Heck it's something understood by accountants ... so it can't be 'that' difficult..." -- Healdem
    "...teach a man to code and he'll be frustrated for life! " -- georgev

Posting Permissions

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