setfocus on textbox

S

seeker

I have a form which opens another form and on load the second form has a text
box whose focus is set. I then have to hit tab in order to start typing
within the textbox. How can I be able to start typing in the textbox as soon
as the form opens/loads. Thanks.
 
A

Arvin Meyer [MVP]

Set the Tab Order for the field you want to start in to 0 in the property
sheet for that control.
 
S

seeker

the following code is in onload of form:

txtNameSearch.SetFocus
txtNameSearch.TabIndex = 0
I also have tabindex set to 0 on this text box and it still does not show
for entry when the form opens. Thanks for suggestions so far.
 
S

seeker

0 in the property sheet as far as tabindex and the textbox only receives if i
click in the textbox after the form opens. I took away the setfocus and
tabindex from onload and all that is is 0 for tabindex on property sheet.
Thanks.
 
S

seeker

when i open the form in question by clicking on it in the form tab it does
just what it is suppose to. The problem evidently is when i open this form
from another form. following is the code that opens if from the other form;

Private Sub TRA_TOWHOM_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyF5 Then
DoCmd.OpenForm "frmNameSearch", acNormal
End If
End Sub

why is this? thanks.
 
S

Stuart McCall

seeker said:
when i open the form in question by clicking on it in the form tab it does
just what it is suppose to. The problem evidently is when i open this
form
from another form. following is the code that opens if from the other
form;

Private Sub TRA_TOWHOM_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyF5 Then
DoCmd.OpenForm "frmNameSearch", acNormal
End If
End Sub

why is this? thanks.
<snip> "seeker" wrote:

Try disposing of the keypress:

DoCmd.OpenForm ...
KeyCode = 0
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top