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

VB Code for TAB Key? 1

Status
Not open for further replies.

jdegeorge

Programmer
Mar 19, 2002
1,313
US
Does anyone know the VB code for the tab key? What I'm trying to do is set the focus to a field, assign a value to that field, and enter the TAB keystroke. I just don't know VB well enough to know all the keystroke code. Please help!!!

Jim DeGeorge [wavey]
 
I don't know if this will work, but have you tried setting focus to the next field?

hth,
GGleason
 
Yes. I tried setting the focus to every other field on the form and unless I actually use the tab key it won't go to a new record. I also tried the code to add a new record (copied from the code of an ADD button) and it wouldn't work either. I'm really stumped!

Jim DeGeorge [wavey]
 
Also, I know that the VB code for the tab character is vbTab, but I don't believe that's what I want. I need to eumulate the actual tab keystroke![sadeyes]

Jim DeGeorge [wavey]
 
setting the focus should work.... if it doesn't (as you say), then what you want is to **shudder** use the sendkeys function to emulate pressing the tab key....

I've not used it for a long time... I really don't like using it, as it has a tendency to be hard to manipulate... especially if you have another program running that brings itself forward before the sendkeys code runs.... since the sendkeys code (if I'm remembering correctly) will work on the active window....

so... the sendkeys function is what you want. It should be in the help file...


GComyn
 
Hi jdegeorge,

I'm not sure what you're really trying to achieve here, but one thing at a time.

Where (that is, in what code) are you trying to set the focus to a field. I don't personally like this but if you set the focus to another field you don't want focused and then set it back to the field you do want it may well work. The reason for this seems to be that setting the focus works fine but you are often thwarted by Access then setting it somewhere else before the screen is redisplayed; setting it twice seems to tell Access that you really mean it and it doesn't then override your wishes.

Now, you don't need to set the focus to a field to assign a value to it so you must be doing it simply because you know thaat TABbing from it produces the result you want. That is a bit dangerous as design changes could change the effect of TABbing. Wouldn't it be better to do what you want directly which sounds like going to a new record in a form - from memory it's something like DoCmd.gotorecord ,,acnewrec.

Enjoy,
Tony
 
GComyn

I tried [tt]SendKeys "{TAB}", False[/tt]

It worked! Thanks so very much! Enjoy the star.

Tony, thanks for your idea, too!

Jim DeGeorge [wavey]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top