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

Access 2002: Setfocus problem.

Status
Not open for further replies.

dreman

Programmer
Jan 16, 2002
272
0
0
US
I have a date range entry into a form:
Enter Date From: 99/99/99 To: 99/99/99
An On Exit Event procedure is set for to date:
Private Sub On_exit_click()
If fromDate>toDate then
MsgBox "Date range Incorrect", vbCritical, "Entry"
Me!ToDate.SetFocus 'refocus on Todate
End if
End Sub
The problem is if error triggers, it will display the message and then continue on the next entry.
I want that if the event is trigggered not to allow the user to continue but rather go back to the toDate. I thought the setfocus will do that.
Please advise on solution.
Thank you.
Dré
 
Hi dreman

You need to temporarily set the focus to another control, then set the focus back to ToDate, rename AnotherControl to one of your own controls.

Private Sub On_exit_click()
If fromDate > ToDate Then
MsgBox "Date range Incorrect", vbCritical, "Entry"
Me!AnotherControl.SetFocus
Me!ToDate.SetFocus 'refocus on Todate
End If
End Sub

Bill
 
Perfect, it worked, now why is that ?
Thank you,
Dré
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top