Move focus from parent form to subform

  • Thread starter Randy Christiansen
  • Start date
R

Randy Christiansen

I have tried everything and read everything I can find on this very basic
event. I need to create an event that will move the focus from the parent
form to the sub form and set the focus to a field. This is what I am
currently using.

Dim ctl As Control
Set Ctl = [BillingCompany]![DeliverySubform].Form![ShipDate]
DoCmd.GoToControl ctl.Name

BillingCompany is the parent, DeliverySubform is the subform and shipdate is
the field on the deliverysubform that I want move the focus to.

I can't seem to get my head around this one. Any help will be greatly
appreceiated.
 
A

Allen Browne

Each form (main and subform) has its own active control.
Therefore you need 2 steps:
1. Make the subform the active control on the main form.
2. Set the active control in the subform.

Assuming this code is running in the main form's module:
Me.Sub1.SetFocus
Me.Sub1.Form!ShipDate.SetFocus

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

message
news:[email protected]...
 
R

Randy Christiansen

That worked very nicely. Thank you so much for your help.

Allen Browne said:
Each form (main and subform) has its own active control.
Therefore you need 2 steps:
1. Make the subform the active control on the main form.
2. Set the active control in the subform.

Assuming this code is running in the main form's module:
Me.Sub1.SetFocus
Me.Sub1.Form!ShipDate.SetFocus

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

message
I have tried everything and read everything I can find on this very basic
event. I need to create an event that will move the focus from the parent
form to the sub form and set the focus to a field. This is what I am
currently using.

Dim ctl As Control
Set Ctl = [BillingCompany]![DeliverySubform].Form![ShipDate]
DoCmd.GoToControl ctl.Name

BillingCompany is the parent, DeliverySubform is the subform and shipdate
is
the field on the deliverysubform that I want move the focus to.

I can't seem to get my head around this one. Any help will be greatly
appreceiated.
 

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