Calculating the Total

T

Thorson

I currently have a sub-report in my Main report. The sub-report has the
label births and field "CountOfEarTag". I would like to add the Value of
"CountOfEarTag" to the disposition head count I have in the main report. The
problem is that I can't get the equation to work when there are no new animal
births and therefore "CountOfEarTag" shows up as nothing. I tried turning
the equation into an If/then, but I'm having problems getting it to work:

=Sum([SumofHead])+(IIf(IsNull([CountOfEarTag]),"0",([CountOfEarTag])))

For some reason it is not recognizing "CountOfEarTag" and asks for it when I
open the report.
What did I do wrong?
Thanks
 
J

JED

Try qualifying the CountOfEarTag with the subreport's name as follows:

=Sum([SumofHead])+(IIf(IsNull([subreport'sname]![CountOfEarTag]),"0",([subre
port'sname]![CountOfEarTag])))
 
M

Marshall Barton

Thorson said:
I currently have a sub-report in my Main report. The sub-report has the
label births and field "CountOfEarTag". I would like to add the Value of
"CountOfEarTag" to the disposition head count I have in the main report. The
problem is that I can't get the equation to work when there are no new animal
births and therefore "CountOfEarTag" shows up as nothing. I tried turning
the equation into an If/then, but I'm having problems getting it to work:

=Sum([SumofHead])+(IIf(IsNull([CountOfEarTag]),"0",([CountOfEarTag])))

For some reason it is not recognizing "CountOfEarTag" and asks for it when I
open the report.


If you are using a newer version of Access, you need to use
the Report property to get to a control in the subreport.

Use the HasData property to test for no records in the
subreport.

Do not put quotes around a number value.

IIf(subreport.Report.HasData,subreport.Report.CountOfEarTag],0)
 
T

Thorson

I tried that, the equation is now:
=Sum([SumofHead])+(IIf(IsNull(Reports!rptURBMonthlyBirthsCountsubreport!CountOfEarTag),"0",(Reports!rptURBMonthlyBirthsCountsubreport!CountOfEarTag)))

It did solve the problem of the report not recognizing CountOfEarTag,
however now instead of calculating it the answer just comes up as #Name?

Any Suggestions???


JED said:
Try qualifying the CountOfEarTag with the subreport's name as follows:

=Sum([SumofHead])+(IIf(IsNull([subreport'sname]![CountOfEarTag]),"0",([subre
port'sname]![CountOfEarTag])))

Thorson said:
I currently have a sub-report in my Main report. The sub-report has the
label births and field "CountOfEarTag". I would like to add the Value of
"CountOfEarTag" to the disposition head count I have in the main report. The
problem is that I can't get the equation to work when there are no new animal
births and therefore "CountOfEarTag" shows up as nothing. I tried turning
the equation into an If/then, but I'm having problems getting it to work:

=Sum([SumofHead])+(IIf(IsNull([CountOfEarTag]),"0",([CountOfEarTag])))

For some reason it is not recognizing "CountOfEarTag" and asks for it when I
open the report.
What did I do wrong?
Thanks
 
T

Thorson

I am using Access 2003, I'm not sure if you mean 2003 or 2007 as a newer
version, I tried to find the "HasData" property under the report properties
and the control properties, but I didn't find it... Maybe I just don't know
where to look.

I did remove the quotes around the 0.

It is still returning the answer as #Name?



Marshall Barton said:
Thorson said:
I currently have a sub-report in my Main report. The sub-report has the
label births and field "CountOfEarTag". I would like to add the Value of
"CountOfEarTag" to the disposition head count I have in the main report. The
problem is that I can't get the equation to work when there are no new animal
births and therefore "CountOfEarTag" shows up as nothing. I tried turning
the equation into an If/then, but I'm having problems getting it to work:

=Sum([SumofHead])+(IIf(IsNull([CountOfEarTag]),"0",([CountOfEarTag])))

For some reason it is not recognizing "CountOfEarTag" and asks for it when I
open the report.


If you are using a newer version of Access, you need to use
the Report property to get to a control in the subreport.

Use the HasData property to test for no records in the
subreport.

Do not put quotes around a number value.

IIf(subreport.Report.HasData,subreport.Report.CountOfEarTag],0)
 
M

Marshall Barton

The Report (and Form) property was optional in A2000 and
earlier. Since then it has been required. Use the Report
property in the references to anything in the subreport and
you can't go wrong in any version.

The HasData property is a read only property set by Access
for each instance of a subreport. It is not a user settable
property and does not appear in a property sheet. You can
read more about it in VBA Help.

#Name means you are using a name that does not appear in
yout report/subreport. Make sure you used the name of the
subreport control where I used "subreport" in the
expression.

What does your expression look like now?
--
Marsh
MVP [MS Access]

I am using Access 2003, I'm not sure if you mean 2003 or 2007 as a newer
version, I tried to find the "HasData" property under the report properties
and the control properties, but I didn't find it... Maybe I just don't know
where to look.

I did remove the quotes around the 0.

It is still returning the answer as #Name?



Marshall Barton said:
Thorson said:
I currently have a sub-report in my Main report. The sub-report has the
label births and field "CountOfEarTag". I would like to add the Value of
"CountOfEarTag" to the disposition head count I have in the main report. The
problem is that I can't get the equation to work when there are no new animal
births and therefore "CountOfEarTag" shows up as nothing. I tried turning
the equation into an If/then, but I'm having problems getting it to work:

=Sum([SumofHead])+(IIf(IsNull([CountOfEarTag]),"0",([CountOfEarTag])))

For some reason it is not recognizing "CountOfEarTag" and asks for it when I
open the report.


If you are using a newer version of Access, you need to use
the Report property to get to a control in the subreport.

Use the HasData property to test for no records in the
subreport.

Do not put quotes around a number value.

IIf(subreport.Report.HasData,subreport.Report.CountOfEarTag],0)
 
T

Thorson

The expression looks like this
=Sum([SumofHead])+(IIf(IsNull(Reports!rptURBMonthlyBirthsCountsubreport!CountOfEarTag),0,(Reports!rptURBMonthlyBirthsCountsubreport!CountOfEarTag)))

The name of the control in the subreport is "CountOfEarTag" THe name of the
control in the main report I would like to add it to is "SumofHead".

When I run the report I still come up with #Name?

I know this has to be something simple I'm missing... Thankyou for your
suggestions.... Do you have any more?

Marshall Barton said:
The Report (and Form) property was optional in A2000 and
earlier. Since then it has been required. Use the Report
property in the references to anything in the subreport and
you can't go wrong in any version.

The HasData property is a read only property set by Access
for each instance of a subreport. It is not a user settable
property and does not appear in a property sheet. You can
read more about it in VBA Help.

#Name means you are using a name that does not appear in
yout report/subreport. Make sure you used the name of the
subreport control where I used "subreport" in the
expression.

What does your expression look like now?
--
Marsh
MVP [MS Access]

I am using Access 2003, I'm not sure if you mean 2003 or 2007 as a newer
version, I tried to find the "HasData" property under the report properties
and the control properties, but I didn't find it... Maybe I just don't know
where to look.

I did remove the quotes around the 0.

It is still returning the answer as #Name?



Marshall Barton said:
Thorson wrote:

I currently have a sub-report in my Main report. The sub-report has the
label births and field "CountOfEarTag". I would like to add the Value of
"CountOfEarTag" to the disposition head count I have in the main report. The
problem is that I can't get the equation to work when there are no new animal
births and therefore "CountOfEarTag" shows up as nothing. I tried turning
the equation into an If/then, but I'm having problems getting it to work:

=Sum([SumofHead])+(IIf(IsNull([CountOfEarTag]),"0",([CountOfEarTag])))

For some reason it is not recognizing "CountOfEarTag" and asks for it when I
open the report.


If you are using a newer version of Access, you need to use
the Report property to get to a control in the subreport.

Use the HasData property to test for no records in the
subreport.

Do not put quotes around a number value.

IIf(subreport.Report.HasData,subreport.Report.CountOfEarTag],0)
 
M

Marshall Barton

If you do not understand what I am trying to explain, please
say so. It make no sense for you to ignore 90% of what I
said and then say it still doesn't work.

For now, get rid of the Sum([SumofHead])+ part of the
expression. I have no idea what you want that part of the
expression to do so leave it out and try to get the rest of
it working.

I can't tell how many problems you have in there but the
Report property is very important and you will get #Name id
you do not use it. Also, IsNull will not work for this, get
rid of it and use the HasData property instead.

Your references to the subreport text box will not work.
The MUST be in the style:
[subreport CONTROL name].Report.CountOfEarTag
--
Marsh
MVP [MS Access]

The expression looks like this:
=Sum([SumofHead])+(IIf(IsNull(Reports!rptURBMonthlyBirthsCountsubreport!CountOfEarTag),
0,(Reports!rptURBMonthlyBirthsCountsubreport!CountOfEarTag)))

The name of the control in the subreport is "CountOfEarTag" THe name of the
control in the main report I would like to add it to is "SumofHead".

When I run the report I still come up with #Name?

I know this has to be something simple I'm missing... Thankyou for your
suggestions.... Do you have any more?

Marshall Barton said:
The Report (and Form) property was optional in A2000 and
earlier. Since then it has been required. Use the Report
property in the references to anything in the subreport and
you can't go wrong in any version.

The HasData property is a read only property set by Access
for each instance of a subreport. It is not a user settable
property and does not appear in a property sheet. You can
read more about it in VBA Help.

#Name means you are using a name that does not appear in
yout report/subreport. Make sure you used the name of the
subreport control where I used "subreport" in the
expression.

What does your expression look like now?

I am using Access 2003, I'm not sure if you mean 2003 or 2007 as a newer
version, I tried to find the "HasData" property under the report properties
and the control properties, but I didn't find it... Maybe I just don't know
where to look.

I did remove the quotes around the 0.

It is still returning the answer as #Name?


:

Thorson wrote:

I currently have a sub-report in my Main report. The sub-report has the
label births and field "CountOfEarTag". I would like to add the Value of
"CountOfEarTag" to the disposition head count I have in the main report. The
problem is that I can't get the equation to work when there are no new animal
births and therefore "CountOfEarTag" shows up as nothing. I tried turning
the equation into an If/then, but I'm having problems getting it to work:

=Sum([SumofHead])+(IIf(IsNull([CountOfEarTag]),"0",([CountOfEarTag])))

For some reason it is not recognizing "CountOfEarTag" and asks for it when I
open the report.


If you are using a newer version of Access, you need to use
the Report property to get to a control in the subreport.

Use the HasData property to test for no records in the
subreport.

Do not put quotes around a number value.

IIf(subreport.Report.HasData,subreport.Report.CountOfEarTag],0)
 
T

Thorson

So far I thought I understood what you said, I followed what you told me to
do, I am sorry I upset you.

The Sum([SumofHead])+ calculates the total animals added and subtracted
through dispositions (transfers, sales, deaths) this control ([SumOfHead]) is
in the main report. I would like to add the sum of the [SumOfHead] to the
CountOfEarTag.

I'll work on correcting the equation to what you have listed,

Thank you for your help

Marshall Barton said:
If you do not understand what I am trying to explain, please
say so. It make no sense for you to ignore 90% of what I
said and then say it still doesn't work.

For now, get rid of the Sum([SumofHead])+ part of the
expression. I have no idea what you want that part of the
expression to do so leave it out and try to get the rest of
it working.

I can't tell how many problems you have in there but the
Report property is very important and you will get #Name id
you do not use it. Also, IsNull will not work for this, get
rid of it and use the HasData property instead.

Your references to the subreport text box will not work.
The MUST be in the style:
[subreport CONTROL name].Report.CountOfEarTag
--
Marsh
MVP [MS Access]

The expression looks like this:
=Sum([SumofHead])+(IIf(IsNull(Reports!rptURBMonthlyBirthsCountsubreport!CountOfEarTag),
0,(Reports!rptURBMonthlyBirthsCountsubreport!CountOfEarTag)))

The name of the control in the subreport is "CountOfEarTag" THe name of the
control in the main report I would like to add it to is "SumofHead".

When I run the report I still come up with #Name?

I know this has to be something simple I'm missing... Thankyou for your
suggestions.... Do you have any more?

Marshall Barton said:
The Report (and Form) property was optional in A2000 and
earlier. Since then it has been required. Use the Report
property in the references to anything in the subreport and
you can't go wrong in any version.

The HasData property is a read only property set by Access
for each instance of a subreport. It is not a user settable
property and does not appear in a property sheet. You can
read more about it in VBA Help.

#Name means you are using a name that does not appear in
yout report/subreport. Make sure you used the name of the
subreport control where I used "subreport" in the
expression.

What does your expression look like now?


Thorson wrote:
I am using Access 2003, I'm not sure if you mean 2003 or 2007 as a newer
version, I tried to find the "HasData" property under the report properties
and the control properties, but I didn't find it... Maybe I just don't know
where to look.

I did remove the quotes around the 0.

It is still returning the answer as #Name?


:

Thorson wrote:

I currently have a sub-report in my Main report. The sub-report has the
label births and field "CountOfEarTag". I would like to add the Value of
"CountOfEarTag" to the disposition head count I have in the main report. The
problem is that I can't get the equation to work when there are no new animal
births and therefore "CountOfEarTag" shows up as nothing. I tried turning
the equation into an If/then, but I'm having problems getting it to work:

=Sum([SumofHead])+(IIf(IsNull([CountOfEarTag]),"0",([CountOfEarTag])))

For some reason it is not recognizing "CountOfEarTag" and asks for it when I
open the report.


If you are using a newer version of Access, you need to use
the Report property to get to a control in the subreport.

Use the HasData property to test for no records in the
subreport.

Do not put quotes around a number value.

IIf(subreport.Report.HasData,subreport.Report.CountOfEarTag],0)
 
T

Thorson

Thank you for your help!! I finally got it to work, your last response was
very helpful, I'm sorry it took me so long to get it. My final equation is:

=(Sum([SumOfHead]))+IIf(rptURBMonthlyBirthsCountsubreport.Report.HasData,rptURBMonthlyBirthsCountsubreport.Report.CountOfEarTag,0)

Thank you!

Marshall Barton said:
If you do not understand what I am trying to explain, please
say so. It make no sense for you to ignore 90% of what I
said and then say it still doesn't work.

For now, get rid of the Sum([SumofHead])+ part of the
expression. I have no idea what you want that part of the
expression to do so leave it out and try to get the rest of
it working.

I can't tell how many problems you have in there but the
Report property is very important and you will get #Name id
you do not use it. Also, IsNull will not work for this, get
rid of it and use the HasData property instead.

Your references to the subreport text box will not work.
The MUST be in the style:
[subreport CONTROL name].Report.CountOfEarTag
--
Marsh
MVP [MS Access]

The expression looks like this:
=Sum([SumofHead])+(IIf(IsNull(Reports!rptURBMonthlyBirthsCountsubreport!CountOfEarTag),
0,(Reports!rptURBMonthlyBirthsCountsubreport!CountOfEarTag)))

The name of the control in the subreport is "CountOfEarTag" THe name of the
control in the main report I would like to add it to is "SumofHead".

When I run the report I still come up with #Name?

I know this has to be something simple I'm missing... Thankyou for your
suggestions.... Do you have any more?

Marshall Barton said:
The Report (and Form) property was optional in A2000 and
earlier. Since then it has been required. Use the Report
property in the references to anything in the subreport and
you can't go wrong in any version.

The HasData property is a read only property set by Access
for each instance of a subreport. It is not a user settable
property and does not appear in a property sheet. You can
read more about it in VBA Help.

#Name means you are using a name that does not appear in
yout report/subreport. Make sure you used the name of the
subreport control where I used "subreport" in the
expression.

What does your expression look like now?


Thorson wrote:
I am using Access 2003, I'm not sure if you mean 2003 or 2007 as a newer
version, I tried to find the "HasData" property under the report properties
and the control properties, but I didn't find it... Maybe I just don't know
where to look.

I did remove the quotes around the 0.

It is still returning the answer as #Name?


:

Thorson wrote:

I currently have a sub-report in my Main report. The sub-report has the
label births and field "CountOfEarTag". I would like to add the Value of
"CountOfEarTag" to the disposition head count I have in the main report. The
problem is that I can't get the equation to work when there are no new animal
births and therefore "CountOfEarTag" shows up as nothing. I tried turning
the equation into an If/then, but I'm having problems getting it to work:

=Sum([SumofHead])+(IIf(IsNull([CountOfEarTag]),"0",([CountOfEarTag])))

For some reason it is not recognizing "CountOfEarTag" and asks for it when I
open the report.


If you are using a newer version of Access, you need to use
the Report property to get to a control in the subreport.

Use the HasData property to test for no records in the
subreport.

Do not put quotes around a number value.

IIf(subreport.Report.HasData,subreport.Report.CountOfEarTag],0)
 
M

Marshall Barton

Thorson said:
Thank you for your help!! I finally got it to work, your last response was
very helpful, I'm sorry it took me so long to get it. My final equation is:

=(Sum([SumOfHead]))+IIf(rptURBMonthlyBirthsCountsubreport.Report.HasData,rptURBMonthlyBirthsCountsubreport.Report.CountOfEarTag,0)


I'm glad you got it do what you want.

I was not upset. I was trying to get you to provide
sufficient feedback so I could try to figure out the
problem.
 

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