how to refer to object in subform

J

Jon

Greeting,

I have a form called mainform and subform called subform1. in the subform1
there is a text box called totalsum and it has the sum funcation as data
source(=Nz(sum(price)) ) and it is located in the subform footer. In main
form, there is a text box which refers to totalsum text box at the subform
but the text box shows “#Name? “
The data source for the text box is “ =[ subform1].Form!Totalsum
“.
Please help
 
A

Allen Browne

Use the Immediate Window to track down what's wrong.

Open the form.

Then press Ctrl+G to open the Immediate Window.
Enter a series of expressions, until you identify where it goes wrong.

Try:
? Forms![mainform].Name
If that works, try:
? Forms![mainform]![subform1].Name
If that works, try:
? Forms![mainform]![subform1].Form!TotalSum.Name

Note that the name of the subform control may be different from the name of
the form that gets loaded into it (its SourceObject.)
 
J

Jon

Hi Allen

I tried them and the result is each expression is giving me a the name: for
example:

? Forms![mainform].Name

Enter

Gives me
Mainform

And so for the reset of expression

Please advice?


Allen Browne said:
Use the Immediate Window to track down what's wrong.

Open the form.

Then press Ctrl+G to open the Immediate Window.
Enter a series of expressions, until you identify where it goes wrong.

Try:
? Forms![mainform].Name
If that works, try:
? Forms![mainform]![subform1].Name
If that works, try:
? Forms![mainform]![subform1].Form!TotalSum.Name

Note that the name of the subform control may be different from the name of
the form that gets loaded into it (its SourceObject.)

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

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

Jon said:
Greeting,

I have a form called mainform and subform called subform1. in the subform1
there is a text box called totalsum and it has the sum funcation as data
source(=Nz(sum(price)) ) and it is located in the subform footer. In main
form, there is a text box which refers to totalsum text box at the subform
but the text box shows “#Name? “
The data source for the text box is “ =[ subform1].Form!Totalsum
“.
Please help
 
A

Allen Browne

They all work?

Then the expression you have should work too.

Does it fail only in some cases?
For example, only when the form is open with no data in it?

Are there other calculated controls that fail as well?

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

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

Jon said:
Hi Allen

I tried them and the result is each expression is giving me a the name:
for
example:

? Forms![mainform].Name

Enter

Gives me
Mainform

And so for the reset of expression

Please advice?


Allen Browne said:
Use the Immediate Window to track down what's wrong.

Open the form.

Then press Ctrl+G to open the Immediate Window.
Enter a series of expressions, until you identify where it goes wrong.

Try:
? Forms![mainform].Name
If that works, try:
? Forms![mainform]![subform1].Name
If that works, try:
? Forms![mainform]![subform1].Form!TotalSum.Name

Note that the name of the subform control may be different from the name
of
the form that gets loaded into it (its SourceObject.)

Jon said:
Greeting,

I have a form called mainform and subform called subform1. in the
subform1
there is a text box called totalsum and it has the sum funcation as
data
source(=Nz(sum(price)) ) and it is located in the subform footer. In
main
form, there is a text box which refers to totalsum text box at the
subform
but the text box shows “#Name? “
The data source for the text box is “ =[ subform1].Form!Totalsum
 
J

Jon

They all work?

Yes, they did

Does it fail only in some cases?
For example, only when the form is open with no data in it?
Yes, it fail when i open the form
Are there other calculated controls that fail as well?
Other Calculated ontrols are working very well


Allen Browne said:
They all work?

Then the expression you have should work too.

Does it fail only in some cases?
For example, only when the form is open with no data in it?

Are there other calculated controls that fail as well?

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

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

Jon said:
Hi Allen

I tried them and the result is each expression is giving me a the name:
for
example:

? Forms![mainform].Name

Enter

Gives me
Mainform

And so for the reset of expression

Please advice?


Allen Browne said:
Use the Immediate Window to track down what's wrong.

Open the form.

Then press Ctrl+G to open the Immediate Window.
Enter a series of expressions, until you identify where it goes wrong.

Try:
? Forms![mainform].Name
If that works, try:
? Forms![mainform]![subform1].Name
If that works, try:
? Forms![mainform]![subform1].Form!TotalSum.Name

Note that the name of the subform control may be different from the name
of
the form that gets loaded into it (its SourceObject.)

Greeting,

I have a form called mainform and subform called subform1. in the
subform1
there is a text box called totalsum and it has the sum funcation as
data
source(=Nz(sum(price)) ) and it is located in the subform footer. In
main
form, there is a text box which refers to totalsum text box at the
subform
but the text box shows “#Name? “
The data source for the text box is “ =[ subform1].Form!Totalsum
 
A

Allen Browne

So it fails when only when the form opens with no data?

If so, see:
Avoid #Error in form/report with no records
at:
http://allenbrowne.com/RecordCountError.html

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

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

Jon said:
They all work?

Yes, they did

Does it fail only in some cases?
For example, only when the form is open with no data in it?
Yes, it fail when i open the form
Are there other calculated controls that fail as well?
Other Calculated ontrols are working very well


Allen Browne said:
They all work?

Then the expression you have should work too.

Does it fail only in some cases?
For example, only when the form is open with no data in it?

Are there other calculated controls that fail as well?

Jon said:
Hi Allen

I tried them and the result is each expression is giving me a the name:
for
example:

? Forms![mainform].Name

Enter

Gives me
Mainform

And so for the reset of expression

Please advice?


:

Use the Immediate Window to track down what's wrong.

Open the form.

Then press Ctrl+G to open the Immediate Window.
Enter a series of expressions, until you identify where it goes wrong.

Try:
? Forms![mainform].Name
If that works, try:
? Forms![mainform]![subform1].Name
If that works, try:
? Forms![mainform]![subform1].Form!TotalSum.Name

Note that the name of the subform control may be different from the
name
of
the form that gets loaded into it (its SourceObject.)

Greeting,

I have a form called mainform and subform called subform1. in the
subform1
there is a text box called totalsum and it has the sum funcation as
data
source(=Nz(sum(price)) ) and it is located in the subform footer. In
main
form, there is a text box which refers to totalsum text box at the
subform
but the text box shows “#Name? “
The data source for the text box is “ =[ subform1].Form!Totalsum
 

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