Tab from field to sub-form control???

  • Thread starter Gulf Coast Electric
  • Start date
G

Gulf Coast Electric

I have a form named DepositSlips and on it I have (2) sub-forms.
I need to after pressing the tab button on the sub-form named Depositor
(Control (Customers)
go to another sub-form named depositsub and go to control (deposit)
I tried this code, but it didnt work.

If KeyCode = Asc(vbTab) Then
Forms!depositsub![Deposit].SetFocus
KeyCode = 0
End If
 
W

Wayne Morgan

To refer to a subform from a main form you need to refer to the name of the
control on the main form that holds the subform, not the name of the
subform. To go from one subform to the other, go up to the main form then
down to the subform. To set the focus to a control, you need to set the
focus to the subform, then to the control.

Me.Parent.subform2.Form.SetFocus
Me.Parent.subform2.Form.Deposit.SetFocus
 
G

Gulf Coast Electric

I dont understand, this doe not work of course.
Main form is DepositSlips, sub form is Depositor and other sub is depositsub
Need to go from sub form Depositor to sub form depositsub amd then go to
control deposit.


Me.Parent.DepositSlips.Form.SetFocus
Me.Parent.Depositor.Form.SetFocus
Me.Parent.depositsub.Form.Deposit.SetFocus

--
-------------------------------------------------------------------------
Thanks for your Help.
Wayne Morgan said:
To refer to a subform from a main form you need to refer to the name of the
control on the main form that holds the subform, not the name of the
subform. To go from one subform to the other, go up to the main form then
down to the subform. To set the focus to a control, you need to set the
focus to the subform, then to the control.

Me.Parent.subform2.Form.SetFocus
Me.Parent.subform2.Form.Deposit.SetFocus

--
Wayne Morgan
Microsoft Access MVP


Gulf Coast Electric said:
I have a form named DepositSlips and on it I have (2) sub-forms.
I need to after pressing the tab button on the sub-form named Depositor
(Control (Customers)
go to another sub-form named depositsub and go to control (deposit)
I tried this code, but it didnt work.

If KeyCode = Asc(vbTab) Then
Forms!depositsub![Deposit].SetFocus
KeyCode = 0
End If
 
W

Wayne Morgan

You shouldn't need to set the focus to the parent (main) form first, just to
the 2nd subform then the control on the 2nd subform. Also, you need to use
the name of the control that holds the subform, not the name of the subform,
although it may turn out that they are both the same. To get the name of
this control, open the main form in design mode, open the Properties sheet,
click on the subform ONE time. The Properties sheet will show the name of
the subform control. If you click on the subform a second time, you'll be in
the subform and the Properties sheet will show the name of the form, not the
name of the control holding the form.

--
Wayne Morgan
Microsoft Access MVP


Gulf Coast Electric said:
I dont understand, this doe not work of course.
Main form is DepositSlips, sub form is Depositor and other sub is depositsub
Need to go from sub form Depositor to sub form depositsub amd then go to
control deposit.


Me.Parent.DepositSlips.Form.SetFocus
Me.Parent.Depositor.Form.SetFocus
Me.Parent.depositsub.Form.Deposit.SetFocus

--
-------------------------------------------------------------------------
Thanks for your Help.
To refer to a subform from a main form you need to refer to the name of the
control on the main form that holds the subform, not the name of the
subform. To go from one subform to the other, go up to the main form then
down to the subform. To set the focus to a control, you need to set the
focus to the subform, then to the control.

Me.Parent.subform2.Form.SetFocus
Me.Parent.subform2.Form.Deposit.SetFocus

--
Wayne Morgan
Microsoft Access MVP


Gulf Coast Electric said:
I have a form named DepositSlips and on it I have (2) sub-forms.
I need to after pressing the tab button on the sub-form named Depositor
(Control (Customers)
go to another sub-form named depositsub and go to control (deposit)
I tried this code, but it didnt work.

If KeyCode = Asc(vbTab) Then
Forms!depositsub![Deposit].SetFocus
KeyCode = 0
End If

--

-------------------------------------------------------------------------
Thanks for your Help.
 
G

Gulf Coast Electric

I tried this, but it does not work, the sub-form is named depositsub
and contaol is named Deposit

Me.depositsub.Form.SetFocus
Me.depositsub.Form.Deposit.SetFocus

--
-------------------------------------------------------------------------
Thanks for your Help.
Wayne Morgan said:
You shouldn't need to set the focus to the parent (main) form first, just to
the 2nd subform then the control on the 2nd subform. Also, you need to use
the name of the control that holds the subform, not the name of the subform,
although it may turn out that they are both the same. To get the name of
this control, open the main form in design mode, open the Properties sheet,
click on the subform ONE time. The Properties sheet will show the name of
the subform control. If you click on the subform a second time, you'll be in
the subform and the Properties sheet will show the name of the form, not the
name of the control holding the form.

--
Wayne Morgan
Microsoft Access MVP


Gulf Coast Electric said:
I dont understand, this doe not work of course.
Main form is DepositSlips, sub form is Depositor and other sub is depositsub
Need to go from sub form Depositor to sub form depositsub amd then go to
control deposit.


Me.Parent.DepositSlips.Form.SetFocus
Me.Parent.Depositor.Form.SetFocus
Me.Parent.depositsub.Form.Deposit.SetFocus

--
-------------------------------------------------------------------------
Thanks for your Help.
To refer to a subform from a main form you need to refer to the name
of
the
control on the main form that holds the subform, not the name of the
subform. To go from one subform to the other, go up to the main form then
down to the subform. To set the focus to a control, you need to set the
focus to the subform, then to the control.

Me.Parent.subform2.Form.SetFocus
Me.Parent.subform2.Form.Deposit.SetFocus

--
Wayne Morgan
Microsoft Access MVP


I have a form named DepositSlips and on it I have (2) sub-forms.
I need to after pressing the tab button on the sub-form named Depositor
(Control (Customers)
go to another sub-form named depositsub and go to control (deposit)
I tried this code, but it didnt work.

If KeyCode = Asc(vbTab) Then
Forms!depositsub![Deposit].SetFocus
KeyCode = 0
End If

-------------------------------------------------------------------------
Thanks for your Help.
 
W

Wayne Morgan

Ok, I just double checked what I gave you. Leave "Form" out of the first
line and it should work.

Me.Parent.depositsub.SetFocus
Me.Parent.depositsub.Form.Deposit.SetFocus

--
Wayne Morgan
Microsoft Access MVP


Gulf Coast Electric said:
I tried this, but it does not work, the sub-form is named depositsub
and contaol is named Deposit

Me.depositsub.Form.SetFocus
Me.depositsub.Form.Deposit.SetFocus

--
-------------------------------------------------------------------------
Thanks for your Help.
You shouldn't need to set the focus to the parent (main) form first,
just
to
the 2nd subform then the control on the 2nd subform. Also, you need to use
the name of the control that holds the subform, not the name of the subform,
although it may turn out that they are both the same. To get the name of
this control, open the main form in design mode, open the Properties sheet,
click on the subform ONE time. The Properties sheet will show the name of
the subform control. If you click on the subform a second time, you'll
be
in
the subform and the Properties sheet will show the name of the form, not the
name of the control holding the form.

--
Wayne Morgan
Microsoft Access MVP


Gulf Coast Electric said:
I dont understand, this doe not work of course.
Main form is DepositSlips, sub form is Depositor and other sub is depositsub
Need to go from sub form Depositor to sub form depositsub amd then go to
control deposit.


Me.Parent.DepositSlips.Form.SetFocus
Me.Parent.Depositor.Form.SetFocus
Me.Parent.depositsub.Form.Deposit.SetFocus

--

-------------------------------------------------------------------------
Thanks for your Help.
To refer to a subform from a main form you need to refer to the name of
the
control on the main form that holds the subform, not the name of the
subform. To go from one subform to the other, go up to the main form then
down to the subform. To set the focus to a control, you need to set the
focus to the subform, then to the control.

Me.Parent.subform2.Form.SetFocus
Me.Parent.subform2.Form.Deposit.SetFocus

--
Wayne Morgan
Microsoft Access MVP


I have a form named DepositSlips and on it I have (2) sub-forms.
I need to after pressing the tab button on the sub-form named
Depositor
(Control (Customers)
go to another sub-form named depositsub and go to control
(deposit)
I tried this code, but it didnt work.

If KeyCode = Asc(vbTab) Then
Forms!depositsub![Deposit].SetFocus
KeyCode = 0
End If

-------------------------------------------------------------------------
Thanks for your Help.
 
G

Gulf Coast Electric

Thank You, that did the trick.


--
-------------------------------------------------------------------------
Thanks for your Help.
Wayne Morgan said:
Ok, I just double checked what I gave you. Leave "Form" out of the first
line and it should work.

Me.Parent.depositsub.SetFocus
Me.Parent.depositsub.Form.Deposit.SetFocus

--
Wayne Morgan
Microsoft Access MVP


Gulf Coast Electric said:
I tried this, but it does not work, the sub-form is named depositsub
and contaol is named Deposit

Me.depositsub.Form.SetFocus
Me.depositsub.Form.Deposit.SetFocus

--
go
to
control deposit.


Me.Parent.DepositSlips.Form.SetFocus
Me.Parent.Depositor.Form.SetFocus
Me.Parent.depositsub.Form.Deposit.SetFocus

-------------------------------------------------------------------------
Thanks for your Help.
message
To refer to a subform from a main form you need to refer to the
name
of
the
control on the main form that holds the subform, not the name of the
subform. To go from one subform to the other, go up to the main form
then
down to the subform. To set the focus to a control, you need to
set
the
focus to the subform, then to the control.

Me.Parent.subform2.Form.SetFocus
Me.Parent.subform2.Form.Deposit.SetFocus

--
Wayne Morgan
Microsoft Access MVP


I have a form named DepositSlips and on it I have (2) sub-forms.
I need to after pressing the tab button on the sub-form named
Depositor
(Control (Customers)
go to another sub-form named depositsub and go to control
(deposit)
I tried this code, but it didnt work.

If KeyCode = Asc(vbTab) Then
Forms!depositsub![Deposit].SetFocus
KeyCode = 0
End If

-------------------------------------------------------------------------
Thanks for your Help.
 

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