Solved

How to count rows/records in a dbgrid?

Posted on 1997-11-11
3
313 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
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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
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…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

792 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