How to get a field value

danielcmr

New member
Local time
Today, 08:17
Joined
Sep 28, 2010
Messages
5
Access.JPG

Hello.

In the image, I have the blue fields working as I want, the green field too (is the sum of the blue fields), but I can't get the red field to work. It should give the sum of all green fields. Can anyone help, please?

Many thanks
 
Welcome to the forum.

Perform the "green" calculations in the record source of your report. So your report's record source should be a query.

Perform the "blue" calculation by adding up the fields.

Perform the "red" calculation to SUM all the "green" calculated fields.
 
A little additional information for you -

With reports you need to refer to the FIELDS for your calculations and not the controls. Also, when doing calculated controls in reports, you can't refer to the other control if it has a calculation; you need to recreate that calculation in the aggregated control. For example, if you have two controls on your report named txtX and txtY and the fields are named X and Y respectively. And txtX has a calculation of say =[FieldName1] + [FieldName2] and control txtY has a control source of =[FieldName3]*[FieldName4).

You can't sum them in the footer by using
=Sum(txtX+txtY)

You would need to use

=Sum(([Field1]+[Field2])+([Field3]*[Field4]))

you have to recreate the entire calculation.

Also, any fields that are referenced on a report in a calculation should not have the same name as the control because then Access throws a #Name error because it doesn't know which you mean and you want to use the field and not the control name.
 
Welcome to the forum.

Perform the "green" calculations in the record source of your report. So your report's record source should be a query.

Perform the "blue" calculation by adding up the fields.

Perform the "red" calculation to SUM all the "green" calculated fields.

The problem is that the green fields are very complex and I use DSearch to calculate them. And how can I SUM all the green fields? I can't do sum(field1,field2,field3).
 
I finaly came with the soluction of calculate de red field all alone, with Dsearchs, sorry DLookups, not depending of the other ones. For now seems to work.

Thanks guys.
 
Last edited:
What is a DSearch?
Looks like the OP's custom function used in the textboxes. DPesquisar could read DSearch.

I just googled that word and it means to investigate (or something like that) :D
 
Looks like the OP's custom function used in the textboxes. DPesquisar could read DSearch.

I just googled that word and it means to investigate (or something like that) :D
Sorry, I meant DLookup. I edited my previous post.
 
You might want to investigate using s subreport instead. I suspect that the records you're pulling in for those three controls relate to the same table or query.
 
You might want to investigate using s subreport instead. I suspect that the records you're pulling in for those three controls relate to the same table or query.
Yes, you're right. I got to have a look at that, but right now I'm just happy to get that ready for tomorrow.
 

Users who are viewing this thread

Back
Top Bottom