Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Adding record count to a report 2

Status
Not open for further replies.

RnRExpress

Technical User
Oct 24, 2004
53
US
I created a query and saved it as a report. Basically, it prints out a packing list for me. But what I would like to see, is there are 12 line items on this report, I would like to add a simple line at the bottom of the report saying "Total Line Items" and have a 12 next to it.

I tried playing around by adding one of the report fields, and using the Count expression, but each time I just get a !Error, or something like that instead of a count.

Thaks for any advice/help!

Richard
 
Actuaklly, the error I got was #Error.

It was when I added an unbound text box, and used
Count ([Record ID]).

Richard
 
Create a calculated field in your query and set its value as "1" e.g. CountLines:1.

Then in the Report Footer or in a Group Footer create an unbound text field and set its value to -

="Total Line Items = " & Sum([CountLines])

 
Payback,

Sorry but that doesn't make sence.

1) If I do make that field in my query, very time I save the query and reopen it afterwards, that field is never saved.

2) If I add your code into an unbound text field on my report, I always get "The expression has an extra )" error.

Richard
 
Payback,

Also, when I do try and add hat calculating field; the query now always prompts me to enter "CountLines"

Sorry I am being so dumb about this but I am realy new to this.

Richard
 
Hi

Paybacks method will work too

in the query grid make a column so CountLines:1

save the query

run the query, ensure

you DO NOT get prompted for CountLines

you can see the CountLines column in the reult with 1 in each line

do as payback says and add the control to the report with source of:

="Total Line Items = " & Sum([CountLines])


Regards

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
Website needs upgrading, but for now - UK
 
Ken,

Thanks.

I added the COuntLines:1 back into the query and for some rason it is working now. Each line shows a colum called "CountLines" and dislays a 1

But when I cut and pasted your code into an unbound text box on the report itself, I still get a #Error instead of a total.

I even went back and tried to use the =Count([Record ID]) and that too, gets the #Error instead of the number.

I must be doing somethign wrong...

Richard
 
Hi

"But when I cut and pasted your code into an unbound text box on the report itself, I still get a #Error instead of a total.

I even went back and tried to use the =Count([Record ID]) and that too, gets the #Error instead of the number."

You cannot mix the two solutions.

Taking paybacks solution

You have successfully changed the query

Now in the detail section make a control (CountLines) which is bound to CountLines column in the query, set its visible property to false

Now in the footer section put the control with ="Total Line Items = " & Sum([CountLines])

try that





Regards

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
Website needs upgrading, but for now - UK
 
Ken,

I added the CountLine item to the detail section and hid that item.

Then I added the unbound text box in the page footer, and pasted your code in.

I still get the #Error.

As for the =Count[Record ID], I tried that totally separate. I didn't mix the two.
 
Hi

"Then I added the unbound text box in the page footer, and pasted your code in.

I still get the #Error."

Have you given the unbound textbox a name?, if yes please be sure it is NOT CountLines, make it (say) txtCountLines


Regards

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
Website needs upgrading, but for now - UK
 
Ken,

The name of my unbound text box is "TextBox25" - I never changed the name that was automatically given to it when I added it to the form.

Oh well, I will probably just give up on this for now. Seemed like a simple thing and from what you have all helped with, it should be a simple thing. But for some reason, its not working in my database.

Richard
 
Just try copying and pasting the following line EXACTLY as it is (quotes, equal signs, etc.)

="Total Line Items = " & Sum([CountLines])

I assume that you can also Sum (total) other fields on your report and it is not a references issue.
 
Payback,

I did cut and paste the code from your message as well as the ones from previous messages. Still get the #Error.

But I think I might know why.

If I move the unbound box into the Report's Detailed section, it works. But if I leave it in the Report Page Footer section, thats when I get the #Error.

Richard
 
hey guys,

I got it to work. If you leave that code in the Page Footer, it fails. If you move it to the report footer, it works.

thanks to all for your help and patience!!!

Richard
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top