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

SendKeys "{tab}" Keyboard Lock

Status
Not open for further replies.

Qamgine

Programmer
Mar 6, 2001
126
US
Okay,

My client is used to a UNIX system in which during data entry to move from field to field they press the Enter Key. I know it's not coding correct to assign the Enter key as the tab key, but this is the way they want it.

Here's my code:

Private Sub txtFirstName_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
SendKeys "{tab}"
KeyAscii = 0
End If
End Sub

Now this works, however I noticed that if I hit the enter key too fast to get through my fields my keyboard locks up and I have to go into control panel and change a keyboard option to get it to work again. When I do it slowly, I notice that the num lock light blinks off and then on whenever I press enter to go through the fields.

My question is (seeing that this code is provided by Microsoft is there a better way to change the enter key default behavior on a control, or why is my keyboard locking up the way it is?
 
Nevermind,

The problem doesn't happen when I compile the program. It only happens inside of VB6 during an F5 runtime.
 

It's not nice to bump, and especially on the same day when the thread was started. And I know it may be important...
Think if everyone did this?
If you wait a couple of days then maybe you could just add a nice post asking if anyone can help further.
Please do not do this again.


To your question, the problem is you would need to know which control is then next control with a TabIndex of the Active control's TabIndex + 1, and then if this control has the TabStop set to True. If you keep track of this, then you can set focus to that control:

Private Sub txtFirstName_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
txtLastName.SetFocus
End If
End Sub

Alot of work however if you change the tab orders....
 
CCLINT>
>>Please do not do this again.
Board Police? Settle down, it was a simple bump.

Sorry but your work around is incorrect. Imagine a Data entry form with over 25 fields to input. Then the client decides that he wants txtLastName to be first and you hardcoded that on txtFirstName to go to txtLastName. You then have to spend a bunch of time reprogramming. The way I did it, you only have to change the Tab Index of maybe a couple of controls and Viola! And like I said I already fixed it.
 
Qamgine
This forum tends to be nice and polite, and mainly self-policed. I see that this is your very first post in the forum, so you may not be aware of this forum's etiquette.

As CCLINT says, a bump in one day seems to be a bit impatient.


________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'People who live in windowed environments shouldn't cast pointers.'
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top