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

  • Thread starter Jordan C. Schroeder
  • 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!
 
K

Klatuu

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top