Setting focus

CCIDBMNG

Registered User.
Local time
Today, 00:07
Joined
Jan 25, 2002
Messages
154
I have a data-entry form and I want to put validation on all of my text boxes and combo boxes after the user enters the information and if it's wrong I want to set the focus back to the text box or combo box they just entered. I tried doing it in the lost focus but I can't put the focus back. I tried to do it in the before update or change events but then the user would have to use the mouse to select something from the combo box. Could someone please help.
 
You should be able to use the BeforeUpdate event for text boxes. The Change event of combo boxes should work whether they use the keyboard or the mouse to select. Alternatively you could consider using Form level BeforeUpdate. Use Cancel = True to send them back to the same box. It sounds like you're trying to reinvent the wheel unnecessarily.

What code are you trying to use currently?

David R


[This message has been edited by David R (edited 03-19-2002).]
 
This is the code I used

Private Sub Combo88_AfterUpdate()
s$ = "Are you sure"

If MsgBox(s$, vbYesNo) = vbYes Then
If Combo88 = "Rejected" Then
Label91.Visible = True
Text90.Visible = True
Text90.SetFocus
Exit Sub
End If
If Combo88 = "Sale" Then
Label91.Visible = False
Text90.Visible = False
Text90.TabStop = False
End If
Else
Combo88 = "Rejected"
Combo88.SetFocus
End If
End Sub

and when they tab out of the combo box nothing happens.
 
Huh? Confusion reigns.
If you've got a combo box with two possible options, can't you simply set LimitToList = Yes in the properties, thereby eliminating the need to set a 'default' (which is also possible, by the way, and does not require code). Make the field required and they'll have to finish it before they exit that record (you'll have to do a bit of coding to make them enter the field before going on to the next field).
Your code at present asks "Are you sure?" after EVERY change. Not sure if that's intended, though it may be.

Good luck,
David R
 

Users who are viewing this thread

Back
Top Bottom