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

DBGrid and record count

Status
Not open for further replies.

tamara3776

Programmer
Apr 6, 2004
18
US
Hey,
I was wondering if anyone already knows how to do this. After my dbgrid gets populated I would like to count the number of records that are displayed and display the record count on the form. If you know how to do this can you post an answer and help me out.

Thanks
 
Dbgrid reflects all the records in the dataset linked. So its record number is the same of the table or the query:

recno := query1.recordcount;
recno := table1.recordcount;

Cheers
Giovanni Caramia
 
Actually, RecordCount doesn't work with all databases. In particular, most Client Server databases will not automatically provide this information, but xBase and Paradox will.

If you're working with a Client Server database, the easiest way to get this info is through a query:
Code:
Select count(*)
from <same from as the query feeding data to the grid>
where <same where as the query feeding data to the grid>,

You're other option is to count all of the records in the return dataset - but that's not the most efficient way to do it unless you have a VERY small dataset.

-Dell

A computer only does what you actually told it to do - not what you thought you told it to do.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top