SetFocus Method Problem

PaulA

Registered User.
Local time
Today, 14:12
Joined
Jul 17, 2001
Messages
416
Hi, all--

This seems a bit simple, but:

I have two date fields on a report menu form for start date and end date.

If the end date is prior to the start date, I want a message to tell the user that and to have the enddate field become null with the focus set on that control.

The null part works fine, but the focus always goes to the next control in tab order and never to the end date control.

My code is this:

Private Sub EndDate_AfterUpdate()
If Me.EndDate < Me.StartDate Then
MsgBox "End Date Cannot Be Prior to Start Date"
Me.EndDate = Null
Me.EndDate.SetFocus
End If
End Sub


Any suggestions?

Thanks.
 
Why not use the End Date control's BeforeUpdate() event? That way the focus won't leave the control until the date is valid.
 
Duhhhh!

Thanks!
 
Try setting the focus to enddate before assigning a null value to it. I noticed you assign null to endate and then setfocus to it. I recall that Access would remind you that it cannot assign values to some controls without first setting focus to it.
 

Users who are viewing this thread

Back
Top Bottom