Form Control Focus

  • Thread starter Thread starter Christopher Robin
  • Start date Start date
C

Christopher Robin

I have two simple forms, and one I open with the On Double Click event of the
main form.

DoCmd.OpenForm "Payees", , , , , acDialog, "GotoNew"

On the Payees form, I have the following code:

If Me.OpenArgs = "GotoNew" And Not IsNull(Me![PayeeName]) Then
DoCmd.GoToRecord , , acNewRec
End If

The code actually works but does have one odd side effect and that is that I
have no idea, where the focus is. If I double click on the main form's
control and the new form opens, I have to tab to actually be able to start
typing the new data. There is only one control on this form and its tab stop
is 0. When I try to use the SetFocus method, Access complains.

Any ideas how to resolve this problem?

TIA,
Chris
 
In reality, you have more than one control on your form. When you open a
form, the first control in the form's tab order that is capable of taking the
focus is the control that will have the focus when the form is opened. Given
that and the fact that the SetFocus is not working for you indicates there is
some setting in the control's properties that is preventing it from accepting
the focus.
 
Well, I'm not exactly sure, what I was doing wrong previously, but I did get
the SetFocus method to work. Maybe your response is all it took. =D

Thanks!!

Klatuu said:
In reality, you have more than one control on your form. When you open a
form, the first control in the form's tab order that is capable of taking the
focus is the control that will have the focus when the form is opened. Given
that and the fact that the SetFocus is not working for you indicates there is
some setting in the control's properties that is preventing it from accepting
the focus.

--
Dave Hargis, Microsoft Access MVP


Christopher Robin said:
I have two simple forms, and one I open with the On Double Click event of the
main form.

DoCmd.OpenForm "Payees", , , , , acDialog, "GotoNew"

On the Payees form, I have the following code:

If Me.OpenArgs = "GotoNew" And Not IsNull(Me![PayeeName]) Then
DoCmd.GoToRecord , , acNewRec
End If

The code actually works but does have one odd side effect and that is that I
have no idea, where the focus is. If I double click on the main form's
control and the new form opens, I have to tab to actually be able to start
typing the new data. There is only one control on this form and its tab stop
is 0. When I try to use the SetFocus method, Access complains.

Any ideas how to resolve this problem?

TIA,
Chris
 
Back
Top