setfocus on textbox

  • Thread starter Thread starter seeker
  • Start date Start date
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.
 
Set the Tab Order for the field you want to start in to 0 in the property
sheet for that control.
 
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.
 
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.
 
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.
 
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
 
Back
Top