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!!!
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!
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...
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.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.