Results 1 to 4 of 4
  1. #1
    markjkubicki's Avatar
    markjkubicki is offline Competent Performer
    Windows 10 Access 2013 64bit
    Join Date
    Jul 2010
    Location
    Fire Island Pines, NY
    Posts
    496

    control undo

    (feel kinda stupid not being able to EVER get this one right... never-the-less)

    ought to be easy: on a Main Form, I have a bound control,
    behind it, this code in the BeforeUpdate event (I could move it to the NotInList event - if that makes more sense):
    it contains the line: Me.ActiveControl.Undo, but it does not "UNDO"



    (I'm using me.ActiveControl in lieu of the control's name as I will eventually be using this code several time for different controls on this form...)

    Code:
    Private Sub cboEnergyCode_BeforeUpdate(Cancel As Integer)
        Dim blnExistingStandard As Boolean
        blnExistingStandard = DCount("[strCode]", "tblCodes", "[strCode] = '" & Me.ActiveControl & "'") > 0
        If Not blnExistingStandard Then
            gsMsgTitle = "UNRECOGNIZED CODE"
            gsMsgText = "'" & UCase(Me.ActiveControl) & "'  is not yet in the Master Database;" _
                & vbCrLf _
                & vbCrLf _
                & vbCrLf & "Do you want to add it?" _
                & vbCrLf _
                & vbCrLf & "(If you do not, it can still be used in this project; but it will not be available as a pull-down for future ones)"
        
            gsMsgResponse = MsgBox(gsMsgText, vbQuestion + vbYesNoCancel + vbDefaultButton1, gsMsgTitle)
    
            Select Case gsMsgResponse
                Case Is = 6 'yes, ADD to the MDb
                       '<...>   
                Case Is = 7 'no, just use in this project
                       '<...>  
                Case Else   'cancel, clear entry
                    Me.ActiveControl.Undo  '<--- this line executes without error, yet the control's value remains the same...
            End Select
        End If
    End Sub
    as always with appreciation in advance,
    m.

  2. #2
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,987
    Cancel=True
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  3. #3
    markjkubicki's Avatar
    markjkubicki is offline Competent Performer
    Windows 10 Access 2013 64bit
    Join Date
    Jul 2010
    Location
    Fire Island Pines, NY
    Posts
    496
    that's all it needed ? (and apparently so)
    one day I'll ask why it's needed, but for now... THNX! (it worked)

  4. #4
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,987
    Before update events are used for validation. If the validation fails, cancel=true is used to prevent the update happening
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 4
    Last Post: 11-24-2020, 03:41 PM
  2. to Undo, or not to Undo...
    By Davince in forum Forms
    Replies: 2
    Last Post: 02-19-2015, 07:23 PM
  3. undo delete
    By jaco in forum Access
    Replies: 1
    Last Post: 11-23-2014, 02:46 PM
  4. Undo one action only
    By zoooza84 in forum Access
    Replies: 5
    Last Post: 08-21-2011, 03:04 PM
  5. Replies: 7
    Last Post: 07-15-2011, 08:14 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums