Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Cancel on BeforeUpdate event isn't working 1

Status
Not open for further replies.

ksbigfoot

Programmer
Apr 15, 2002
856
CA
Maybe I am not understanding this correctly. I thought if I did a Cancel = True in my code in the BeforeUpdate event, that the previous value that was in the text box (txtPropertyNewName) would be put back. In my code below, I stepped through it and the Cancel = True does run, but when I go back to the form, the text has not be replaced back into the field (txtPropertyNewName).

Can someone see what I am doing wrong?

Code:
Private Sub txtPropertyNewName_BeforeUpdate(Cancel As Integer)
On Error GoTo Err_txtPropertyNewName_BeforeUpdate

    If IsNull(Me.txtPropertyNewName) Then
        If IsNull(Me.cboPropertyID) Then
            
            MsgBox ("Enter in a new Property before clearing out the Property New Name")
            Cancel = True
            
        End If
    End If

Exit_txtPropertyNewName_BeforeUpdate:
    Exit Sub
Err_txtPropertyNewName_BeforeUpdate:
    MsgBox (Err.Description & ":txtPropertyNewName_BeforeUpdate")
    Resume Exit_txtPropertyNewName_BeforeUpdate
End Sub
 
You may try this:
Cancel = True
Me.txtPropertyNewName.Undo

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Howdy PHV,

That works perfect. Thank You and star to you.

ksbigfoot
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top