Solved

How to count rows/records in a dbgrid?

Posted on 1997-11-11
3
310 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
3 Comments
 
LVL 1

Expert Comment

by:jackb022197
Comment Utility
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
Comment Utility
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
Comment Utility
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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
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…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

772 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now