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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Count records to display in report problem

Status
Not open for further replies.

keepfoxing

Programmer
Dec 9, 2015
37
PH
i have a textbox in a report to display the total number of
records on a table..
im using the reccount() and/or count()
i also set the calculate to count..
but it always displays 0 value even the table has records..


pls help...tnx
 
First, there is no such function as COUNT() - unless you have defined that yourself. There is a COUNT command, but that won't help here.

It should be enough to set the expression to RECCOUNT(). You shouldn't need to do anything with the field's Calculate property.

Are you sure that you are counting the records in the correct table? It's advisable to pass the alias of the relevant table to RECCOUNT() - for example, RECCOUNT("orders").

And where are you placing this field? I'm not sure why, but if you put it in the the report header, it will display zero. If you put it in the summary, it shows the correct value.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
To clarify what I just said (that it shows zero if placed in the report header). That's true if you set the Calculate to Count, but not if you set it to None. I suggest you set it to None anyway, and see what happens.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Reccount is always giving the full count of dbf records, deleted and undeleted, It's not modified by FOR clause you may have used nor by SET DELETED ON, so you better have a report variable you init with 0 and set it to count records.

Bye, Olaf.
 
Or maybe you can do a SELECT COUNT(*)...

kilroy [knight]
philippines

"Once a king, always a king. But being a knight is more than enough."
 
The report can certainly pick up values from a cursor or array.

I'd do something like this:

Code:
Count to lnTotalRecords 
Report form <optional other stuff>

If your report command is scoped (for <expression>) add that same expression to the count and then use the variable lnTotalRecords on the report control.
 
I quite often use Dan's method
Code:
COUNT TO lnTotalRecords <FOR whatever criteria>

Then something has to be done with the resultant value so that it can be utilized on the form.

keepfoxing said:
it always displays 0 value even the table has records

How is the form's Textbox ControlSource defined?
And do you Refresh it after the table has records ?

Good Luck,
JRB-Bldr
 
i got it..
i did not realize it earlier that it was in the header part
of the report..
tnx
 
Then there is a possibility to trigger a two pass run of the report, see
If you include _PAGETOTAL anywhere in a Visual FoxPro report, Visual FoxPro performs two passes through the report.

The pagetotal might be used in a control you set to printwhen .F., so it's not visible, but still causes the two pass run. Or you take it for the usual "page X of Y" in header or footer.

Now I'm unsure about how report variables are reset and or released, there are several settings for that in the report variables dialog. You can play with this. If the count of the first pass is not reset to 0 you would print or preview it in the header in the second pass. If report variables scope end at a pass, you might copy the count value into anoter variable in the report footer or summary band into a variable not maintained by the report and print that in the header section.

Bye, Olaf.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top