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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Order of events 1

Status
Not open for further replies.

OraMs

Programmer
Feb 12, 2000
40
0
0
US
I have a text box with an EXIT event that will check for null value. If null, a message to user is displayed and the focus is set to the text box. Well, that's not what it is doing. It displays message but it goes to next control...

See code below:

Code:
    If Isnull(Me!DOB) Then
        MsgBox "Date of Birth cannot be null.  Please enter.", vbOKOnly
        Me!DOB.SetFocus
    End If

Thanks for any feedback.
 
You need to exit the procedure, i.e., Exit Sub. If the procedure is a funtion, then Exit Function.

If Isnull(Me!DOB) Then
MsgBox "Date of Birth cannot be null. Please enter.", vbOKOnly
Me!DOB.SetFocus
Exit Sub
End If
 

The Exit event of a text box has a Cancel option. Set Cancel to True and remove the SetFocus.

Private Sub DOB_Exit(Cancel As Integer)

If Isnull(Me!DOB) Then
MsgBox "Date of Birth cannot be null. Please enter.", vbOKOnly
Cancel=True
Exit Sub
End If
Terry L. Broadbent
FAQ183-874 contains tips for posting questions in these forums.
NOTE: Reference to the FAQ is not directed at any individual.
 

Hi Terry,

Thanks a lot. It works perfect..

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top