Tab Control Subform SetFocus

T

tbrogdon

My main form has a tab control which has a subform embedded in
datasheet view.

The main form (frmNewProd) has a combo box (cboShift). I want to make
a selection in the combo box, hit <enter> and set the focus to the
first field (WorkstationID) of the first record in the empty subform
(sfmProdOp) which is embedded in the tab control (tabProdDetails).

I have tried attaching the following code to the AfterUpdate event of
the combo box on the main form:

Private Sub cboShift_AfterUpdate()
Me!sfmProdOp.SetFocus
Me!sfmProdOp.Form!WorkstationID.SetFocus
End Sub

but it doesn't go there. I don't actually know where the focus goes. I
want to move to the first field via hitting the <enter> key.
Currently, if I hit enter all that happens is that my form scrolls up
making the top of the form disappear and the cursor does not reappear.
I think the focus is being set to the tab control - I think. On the
other hand, if I hit the <tab> key twice the cursor appears in the
appropriate field. But of course, I don't want to use the <tab> key.

TIA,

Tim
 
B

Beetle

Once the focus is on the subform, you don't need to use the .Form! reference
to refer to the control, so it should be;

Me!sfmProdOp.SetFocus
sfmProdOp!WorkstationID.SetFocus
 
T

tbrogdon

Once the focus is on the subform, you don't need to use the .Form! reference
to refer to the control, so it should be;

Me!sfmProdOp.SetFocus
sfmProdOp!WorkstationID.SetFocus

Hi Sean,

That still isn't accomplishing what I am hoping to do. It does set the
focus to the subform but is there a way to place a flashing cursor
inside the field WorkstationID?

Thanks,

Tim
 

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