Solved

How to count rows/records in a dbgrid?

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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone 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

Title # Comments Views Activity
Delphi 2 91
Multiple image collision 13 108
shape, triangle, dbctrlgrid 3 46
Delphi, TImage, Png 2 53
A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…

734 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