How do I move focus to sub form

  • Thread starter Thread starter Robin Chapple
  • Start date Start date
R

Robin Chapple

I have a sub form on page three of the main form. It is for a little
used function and ensures that it is obviously a separate operation.

The subform name is:
frmMemberClubHistoryTerminated

and I need the cursor to start on the field [Reason]

Page three is selected from a command button in the page footer and I
have tried this in the "OnClick" event.

DoCmd.GoToPage 3
DoCmd.GoToControl "frmMemberClubHistoryTerminated![Reason]"

This gives error 2109.

Thanks,

Robin Chapple
 
This is a 2 step operation, setting focus to the subform control, and then
to the control on the form in the subform control:
Me.frmMemberClubHistoryTerminated.SetFocus
Me.frmMemberClubHistoryTerminated.Form.SetFocus

You can choose the desired tab page by setting the Value of the tab control,
e.g.:
Me.Tab1 = 2
However, that should not be necessary in this case.
 
Robin Chapple said:
I have a sub form on page three of the main form. It is for a little
used function and ensures that it is obviously a separate operation.

The subform name is:
frmMemberClubHistoryTerminated

and I need the cursor to start on the field [Reason]

Page three is selected from a command button in the page footer and I
have tried this in the "OnClick" event.

DoCmd.GoToPage 3
DoCmd.GoToControl "frmMemberClubHistoryTerminated![Reason]"

This gives error 2109.

Try this pair of statements:

Me!frmMemberClubHistoryTerminated.SetFocus
Me!frmMemberClubHistoryTerminated!Reason.SetFocus
 
Thanks Allen,

The second line gave an error message. Dirk's code has worked.

Robin
 
Thanks Dirk,

I had tried Allen's code with partial success. Yours did the trick.

Many thanks,

Robin Chapple

Robin Chapple said:
I have a sub form on page three of the main form. It is for a little
used function and ensures that it is obviously a separate operation.

The subform name is:
frmMemberClubHistoryTerminated

and I need the cursor to start on the field [Reason]

Page three is selected from a command button in the page footer and I
have tried this in the "OnClick" event.

DoCmd.GoToPage 3
DoCmd.GoToControl "frmMemberClubHistoryTerminated![Reason]"

This gives error 2109.

Try this pair of statements:

Me!frmMemberClubHistoryTerminated.SetFocus
Me!frmMemberClubHistoryTerminated!Reason.SetFocus
 
Robin Chapple said:
Thanks Dirk,

I had tried Allen's code with partial success. Yours did the trick.

I believe Allen accidentally left out a word in one of his code lines.
I'm sure he meant to write:

Me.frmMemberClubHistoryTerminated.Form.Reason.SetFocus

or

Me.frmMemberClubHistoryTerminated.Form!Reason.SetFocus

Both of those are equivalent to the version of the statement that I
posted.
 
Back
Top