Solved

How to count rows/records in a dbgrid?

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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

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…
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…
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

778 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