Originally Posted by
LOUM
...When I run the debug i get a compile error with the below code.
Private Sub Combo118_BeforeUpdate(Cancel As Integer)
If IsNull(Me.Combo118) Then
MsgBox "The blank field is required....", vbOKOnly
Me.Combo118.SetFocus
Cancel = True
Exit Sub
End If
End Sub
It states it cannot find Combo118.
How can I find where this was used on a form and which form?
If you're getting a Compile Error Access should be taking you to the code in the Code Module for the Form where it resides! Just look up at the Form Header for the name!
If Combo118 does actually exist on the Form, Access may be balking at the line
Me.Combo118.SetFocus
Located in the Combo118_BeforeUpdate event, the line is not needed; the line
Cancel = True
in the BeforeUdate event, would insure that the Focus will remain in the Control.
But the entire code is located in the wrong event! If the user simply doesn't make a selection from Combo118, the event will never fire and the Validation will not be run! Validation code to insure that a Control is not Null simply has to be in the Form_BeforeUpdate event!
It is quite possible that during development Combo118 was either deleted or re-named.
Linq ;0)>
The problem with making anything foolproof...is that fools are so darn ingenious!
All posts/responses based on Access 2003/2007