Referring to subforms

  • Thread starter Thread starter Tony Williams
  • Start date Start date
T

Tony Williams

I have a form, EditOffence, which has a tabcontrol, Tabctl76, on which there
is a subform, InputAgreement. I have a command button on another form which
has a macro on the onclick event to open the form EditOffence and show the
subform. The form name for the OpenForm in the macro is
Forms![EditOffence]![TabCtl76]![InputAgreement].Form
What's wrong with this because when I execute the macro I get an error
message that says can't find the form
TIA
 
Controls on a tab control are seen by the form as being on the form (the tab
control is not part of the reference). And, you cannot "open" the subform
this way; what you do is set focus to the subform and then it will "appear"
after you open the main form. So, change code to this:

DoCmd.OpenForm "Forms![EditOffence"
DoCmd.SelectObject "Forms![EditOffence]"
Forms![EditOffence]![InputAgreement].SetFocus
 
Thanks Ken but didn't work. Got message Runtime error 2102 The form name
Forms![EditOffence] is misspelled or doesn't exist
Any ideas?
TIA
Tony
Ken Snell said:
Controls on a tab control are seen by the form as being on the form (the tab
control is not part of the reference). And, you cannot "open" the subform
this way; what you do is set focus to the subform and then it will "appear"
after you open the main form. So, change code to this:

DoCmd.OpenForm "Forms![EditOffence"
DoCmd.SelectObject "Forms![EditOffence]"
Forms![EditOffence]![InputAgreement].SetFocus


--
Ken Snell
<MS ACCESS MVP>

Tony Williams said:
I have a form, EditOffence, which has a tabcontrol, Tabctl76, on which there
is a subform, InputAgreement. I have a command button on another form which
has a macro on the onclick event to open the form EditOffence and show the
subform. The form name for the OpenForm in the macro is
Forms![EditOffence]![TabCtl76]![InputAgreement].Form
What's wrong with this because when I execute the macro I get an error
message that says can't find the form
TIA
 
ken I persisted and got it to work with this
DoCmd.OpenForm "EditOffence", , , "[VFU Code]=" & "'" & Me![VFU Code] & "'"
Forms![EditOffence]![InputAgreement].SetFocus
Ken Snell said:
Controls on a tab control are seen by the form as being on the form (the tab
control is not part of the reference). And, you cannot "open" the subform
this way; what you do is set focus to the subform and then it will "appear"
after you open the main form. So, change code to this:

DoCmd.OpenForm "Forms![EditOffence"
DoCmd.SelectObject "Forms![EditOffence]"
Forms![EditOffence]![InputAgreement].SetFocus


--
Ken Snell
<MS ACCESS MVP>

Tony Williams said:
I have a form, EditOffence, which has a tabcontrol, Tabctl76, on which there
is a subform, InputAgreement. I have a command button on another form which
has a macro on the onclick event to open the form EditOffence and show the
subform. The form name for the OpenForm in the macro is
Forms![EditOffence]![TabCtl76]![InputAgreement].Form
What's wrong with this because when I execute the macro I get an error
message that says can't find the form
TIA
 
My apology....I inadvertently had included the "Forms!" text in the OpenForm
argument for form name -- my error!

Glad you got it to work!

--
Ken Snell
<MS ACCESS MVP>

Tony Williams said:
ken I persisted and got it to work with this
DoCmd.OpenForm "EditOffence", , , "[VFU Code]=" & "'" & Me![VFU Code] & "'"
Forms![EditOffence]![InputAgreement].SetFocus
Ken Snell said:
Controls on a tab control are seen by the form as being on the form (the tab
control is not part of the reference). And, you cannot "open" the subform
this way; what you do is set focus to the subform and then it will "appear"
after you open the main form. So, change code to this:

DoCmd.OpenForm "Forms![EditOffence"
DoCmd.SelectObject "Forms![EditOffence]"
Forms![EditOffence]![InputAgreement].SetFocus


--
Ken Snell
<MS ACCESS MVP>

Tony Williams said:
I have a form, EditOffence, which has a tabcontrol, Tabctl76, on which there
is a subform, InputAgreement. I have a command button on another form which
has a macro on the onclick event to open the form EditOffence and show the
subform. The form name for the OpenForm in the macro is
Forms![EditOffence]![TabCtl76]![InputAgreement].Form
What's wrong with this because when I execute the macro I get an error
message that says can't find the form
TIA
 
Thanks Ken at least it made me think a bit!!!
Tony
Ken Snell said:
My apology....I inadvertently had included the "Forms!" text in the OpenForm
argument for form name -- my error!

Glad you got it to work!

--
Ken Snell
<MS ACCESS MVP>

Tony Williams said:
ken I persisted and got it to work with this
DoCmd.OpenForm "EditOffence", , , "[VFU Code]=" & "'" & Me![VFU Code] & "'"
Forms![EditOffence]![InputAgreement].SetFocus
Ken Snell said:
Controls on a tab control are seen by the form as being on the form
(the
tab
control is not part of the reference). And, you cannot "open" the subform
this way; what you do is set focus to the subform and then it will "appear"
after you open the main form. So, change code to this:

DoCmd.OpenForm "Forms![EditOffence"
DoCmd.SelectObject "Forms![EditOffence]"
Forms![EditOffence]![InputAgreement].SetFocus


--
Ken Snell
<MS ACCESS MVP>

I have a form, EditOffence, which has a tabcontrol, Tabctl76, on which
there
is a subform, InputAgreement. I have a command button on another form
which
has a macro on the onclick event to open the form EditOffence and
show
the
subform. The form name for the OpenForm in the macro is
Forms![EditOffence]![TabCtl76]![InputAgreement].Form
What's wrong with this because when I execute the macro I get an error
message that says can't find the form
TIA
 
Back
Top