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!
Klatuu - 20 May 2008 15:29 GMT
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

Signature
Dave Hargis, Microsoft Access MVP
> Hello Experts,
>
[quoted text clipped - 19 lines]
>
> Thanks!