Compile Error: Method or data member not found texbox.undo

  • Thread starter Thread starter Jordan C. Schroeder
  • Start date Start date
J

Jordan C. Schroeder

Hello Experts,

I am trying to compile my database application, but I seem to be running
into an error on one of my forms in the BeforeUpdate event. Here is the code
for my validation:

Private Sub Customer_BeforeUpdate(Cancel As Integer)
If (Customer.Value & vbNullString = vbNullString) Then
MsgBox "Customer is required!", vbOKOnly

Cancel = True

Customer.Undo
Else
End If
End Sub

When I compile it highlights the Customer.Undo line and says Method or data
member not found. Kind of odd since I am using the same statement on another
form which does not produce the error. Any suggestions would be greatly
appreciated.

Thanks!
 
You should always qualify your object names with Me. or Me! or if the objects
are not related to the current form or report, then full name of the external
object reference Forms!NameOfOtherForm!

I would do it like this:

Private Sub Customer_BeforeUpdate(Cancel As Integer)
If Me.Customer & vbNullString = vbNullString Then
MsgBox "Customer is required!", vbOKOnly
Cancel = True
Me.Customer.Undo
End If
End Sub
 
Back
Top