Inconsistent Behavoir Referencing a Control on SubForm (#Name?)

D

Dave

I am getting inconsistent behavior trying to reference a control on a
subform in an Access 2000 database I created.

I have a hidden textbox control on a subform that sums the value of a
particular field for all the records displayed in the subform. This
summation is displayed on the parent form in a visible textbox by setting
the control source of the visible textbox to reference the hidden textbox in
the sub form.

The details are listed below:

PARENT FORM NAME: f_split
NAME: txtTotal
CONTROL SOURCE: =[f_Split_SUB].Form.txtSumSplitPercent

SUB FORM NAME: f_Split_SUB
NAME: txtSumSplitPercent
CONTROL SOURCE: =Sum([splitPercent])

This configuration works fine. However, when I try to use the same
configuration on another form, I get a #Name? error in the textbox control
on the parent form.

For the life of me, I cannot understand why the behavior would be different
between the two forms.

The specifics for the second form are listed below:

PARENT FORM NAME: f_check
NAME: txtCheckAmount
CONTROL SOURCE: =[f_check_SUB].Form.txtSumSplitAmount

SUB FORM NAME: f_check_SUB
CONTROL NAME: txtSumSplitAmount
CONTROL SOURCE: =Sum([splitamount])

I have tried changing the control source reference for the textbox on the
parent form to...

=[Forms]![f_check]!f_check_SUB.Form!txtSumSplitAmount

....but still I get #Name?

I tried embedding the first subform (f_Split_SUB) into the second parent
form and creating the same reference that worked in the first parent form
(f_Split), but still I get a #Name? reference error.

What could possibly be going on that might contribute to this inconsistent
behavior? Could there be some sort of form property setting that is at work
here?
 
J

John Vinson

What could possibly be going on that might contribute to this inconsistent
behavior?

A common possibility is that the Me!subformname.Form! syntax needs the
Name property *of the Subform control*, not that of the Form within
that control - they're not necessarily the same!
 
D

Dave

BLESS YOU. That is precisely the issue.

I had to read your response a couple of times before it sunk in but then it
finally became clear that a subform is really just a control from the parent
form's perspective. And that control's name might be different from the
actual subform name.

Whoa, I spent way too much time troubleshooting this issue.

Thnak you again for clearing it up for me.
 

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