Solved

How to count rows/records in a dbgrid?

Posted on 1997-11-11
3
317 Views
Last Modified: 2010-04-04
I am using a master detail relationship. When i select an item in the master source, the detail records are shown in the dbgrid component. How can i count the records that match, and how to determine wether a dbgrid is empty, eg, no records in the detail table match with the records in the master table....
I hope someone can tell me how to count the records or rows in the dbgrid. There is RowCount method for stringgrid, but not for the dbgrid......
Thanks,
Marcel
0
Comment
Question by:marcelh
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 1

Expert Comment

by:jackb022197
ID: 1349923
I am not sure about this, but isn't it just the Table1.RecordCount that is connected to the grid??
I used it recently, when I had a filtered table (ApplyRange) displayed in a DBGrid descendant.

0
 

Author Comment

by:marcelh
ID: 1349924
Well, could be, i'll try it, but does it work in master-detail relationship?
Thanks anyway!
0
 
LVL 8

Accepted Solution

by:
ZifNab earned 10 total points
ID: 1349925
Marcelh,

If  MasterTable is master table
and DetailTable is detail table then

offcourse like Jackb says, you can use RecordCount.

If you want to know if detailtable is empty, just use

 if DetailTable.RecordCount = 0 then
  showmessage('Table contains no records');

DetailTable.RecordCount will give you the total number of records. Look out for dBase tables! (RecordCount will give you always the total nomber of records, also if you've limited the table with a range. The recordcount will not be affected by the range).

Have fun,
c.u. ZifNab;
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Suggested Courses
Course of the Month7 days, 21 hours left to enroll

617 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question