Tab Control Subform SetFocus

  • Follow


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
0
Reply tbrogdon 1/26/2008 12:32:21 AM

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

-- 
_________

Sean Bailey


"tbrogdon@gmail.com" wrote:

> 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
> 
0
Reply Utf 1/26/2008 4:30:01 AM


> 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
0
Reply tbrogdon 1/26/2008 12:22:40 PM

2 Replies
514 Views

(page loaded in 0.062 seconds)

Similiar Articles:
















7/20/2012 5:11:51 AM


Reply: