Transferring data from main form to subform not working

S

Susan L

I want a control on a subform (on a Tab) to inherit a value under certain
conditions when two other controls on the main form are filled. The code is
in the After Update event of a third control on the main form. The code is
below. I have used the control name that contains the subform, not the name
of the form itself, which I've read at MSDN is the proper syntax.
Have received numerous errors as I've been tinkering, trying to make it
work, but the current message is that Access can't find the control name
Tab7_QUICK (This is not the name of the Tab -- it's the control that holds
the form). I've double-checked the name as well as that of the control on
that subform (txtError). There must be a syntax problem. Here's the code,
along with my comment.

'Enters the QUICK application error on the QUICK Error tab
If Me.[ProgramID] = 5 And Me.[CategoryID] = 2 Then
Forms![Tab7_QUICK]![txtError] = Me.[cboDescription].[Column](3)
End If
Would appreciate any suggestions.
 
K

Ken Snell \(MVP\)

A subform is not open on its own when part of a parent form. Instead, you
must reference it through the parent form, and you must use the name of the
subform control (the control that holds the subform object in the main
form):

Forms!NameOfParentForm!NameOfSubformControl![txtError] =
Me.[cboDescription].[Column](3)
 
S

Susan L

Thanks, Ken. Your response solved not one, but three problems! Thanks again.
--
susan


Ken Snell (MVP) said:
A subform is not open on its own when part of a parent form. Instead, you
must reference it through the parent form, and you must use the name of the
subform control (the control that holds the subform object in the main
form):

Forms!NameOfParentForm!NameOfSubformControl![txtError] =
Me.[cboDescription].[Column](3)
--

Ken Snell
<MS ACCESS MVP>

Susan L said:
I want a control on a subform (on a Tab) to inherit a value under certain
conditions when two other controls on the main form are filled. The code
is
in the After Update event of a third control on the main form. The code is
below. I have used the control name that contains the subform, not the
name
of the form itself, which I've read at MSDN is the proper syntax.
Have received numerous errors as I've been tinkering, trying to make it
work, but the current message is that Access can't find the control name
Tab7_QUICK (This is not the name of the Tab -- it's the control that holds
the form). I've double-checked the name as well as that of the control on
that subform (txtError). There must be a syntax problem. Here's the code,
along with my comment.

'Enters the QUICK application error on the QUICK Error tab
If Me.[ProgramID] = 5 And Me.[CategoryID] = 2 Then
Forms![Tab7_QUICK]![txtError] = Me.[cboDescription].[Column](3)
End If
Would appreciate any suggestions.
 
K

Ken Snell \(MVP\)

Three for the price of one... not a bad deal! Glad it's working for you.
You're welcome.

--

Ken Snell
<MS ACCESS MVP>

Susan L said:
Thanks, Ken. Your response solved not one, but three problems! Thanks
again.
--
susan


Ken Snell (MVP) said:
A subform is not open on its own when part of a parent form. Instead, you
must reference it through the parent form, and you must use the name of
the
subform control (the control that holds the subform object in the main
form):

Forms!NameOfParentForm!NameOfSubformControl![txtError] =
Me.[cboDescription].[Column](3)
--

Ken Snell
<MS ACCESS MVP>

Susan L said:
I want a control on a subform (on a Tab) to inherit a value under
certain
conditions when two other controls on the main form are filled. The
code
is
in the After Update event of a third control on the main form. The code
is
below. I have used the control name that contains the subform, not the
name
of the form itself, which I've read at MSDN is the proper syntax.
Have received numerous errors as I've been tinkering, trying to make it
work, but the current message is that Access can't find the control
name
Tab7_QUICK (This is not the name of the Tab -- it's the control that
holds
the form). I've double-checked the name as well as that of the control
on
that subform (txtError). There must be a syntax problem. Here's the
code,
along with my comment.

'Enters the QUICK application error on the QUICK Error tab
If Me.[ProgramID] = 5 And Me.[CategoryID] = 2 Then
Forms![Tab7_QUICK]![txtError] = Me.[cboDescription].[Column](3)
End If
Would appreciate any suggestions.
 

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