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

Focus change takes several seconds

Status
Not open for further replies.

georgesOne

Technical User
Jul 2, 2004
176
JP
Hi,

I have a form with a few textboxes having events as shown below.

Private Sub tbxUserCell_Change()
If tbxUserCell.text Like "###-###-####" Then
bFree = True
cboDepartment.SetFocus
End If
End Sub

For unknown reasons, it takes a few seconds until cboDepartment gets the focus and lets me edit this field. I can not detect any loops or call repeats in the code. Form and controls are unbound.
I understand there is a conflict between the Change event of this control and the SetFocus command. But I don't know how else I can achieve that after a certain formatted entry the next control receives focus.
Any comment?

Thanks, Georges
 
How are ya georgesOne . . .

Use an [blue]Input Mask[/blue] instead!. For a phone number it would look like:
Code:
[blue]!(999) 000-0000;;_[/blue]

Any attempt to change focus without fulfilling the mask is aborted.

To read about Input Mask, in the table select the field, then put the cursor on the Input Mask line and hit F1.

[blue]Your Thoughts? . . .[/blue]

Calvin.gif
See Ya! . . . . . .

Be sure to see thread181-473997
Also faq181-2886
 
Thanks, Aceman1.

Actually I have set the input mask like !999\-000\-0000;;_

However,after editing the 10 digit number, the focus would not move to the next field.

I came up with a solution though.
I have put the following code into the Key_Up event and it seems to work bautifully:

Private Sub tbxUserPhone_KeyUp(KeyCode As Integer, Shift As Integer)

If tbxUserPhone.text Like "###-###-####" Then
bFree = True
tbxUserCell.SetFocus
End If
End Sub

Thanks for your help.
Kind regrds, georgesOne
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top