If rowcount or recordcount = 0 - show message
I would like to show a message in a label if no rows are found.
The results come from a BDE query and are displayed on a MasterData band.
I've tried using the RowCount property of the MasterData band and the RecordCount of the query.
I've tried it both ways in a click event of an OK button and in the onBeforePrint event of the MasterData band and the label.
I'm using pascal.
Memo8 is the name of my label. It is currently in the Report Title header.
TfrxMasterData is the MasterData band
Encounter holds the result of the query.
I need something like this.
or something like this
or something like this
Any suggestions on what and where? Let me know if I need to provide more info.
Thanks.
The results come from a BDE query and are displayed on a MasterData band.
I've tried using the RowCount property of the MasterData band and the RecordCount of the query.
I've tried it both ways in a click event of an OK button and in the onBeforePrint event of the MasterData band and the label.
I'm using pascal.
Memo8 is the name of my label. It is currently in the Report Title header.
TfrxMasterData is the MasterData band
Encounter holds the result of the query.
I need something like this.
If length(TfrxMasterData.RowCount) = 0 Then begin
      Memo8.Visible := True;                                                                     Â
      Memo8.lines.Text := 'no data';
end Else begin
      Memo8.Visible := False;                                                                     Â
      Memo8.lines.Text := '';
end
or something like this
If TfrxMasterData.RowCount = 0 Then begin
      Memo8.Visible := True;                                                                     Â
      Memo8.lines.Text := 'no data';
end Else begin
      Memo8.Visible := False;                                                                     Â
      Memo8.lines.Text := '';
end
or something like this
If Encounter.RecordCount = 0 Then begin
Memo8.Visible := True;Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â
      Memo8.lines.Text := 'no data';
end Else begin
      Memo8.Visible := False;                                                                     Â
      Memo8.lines.Text := '';
end
Any suggestions on what and where? Let me know if I need to provide more info.
Thanks.
Comments
Good Morning,
try to use the BDE-Query to get the RecordCount.
Add it to the lower begin/end.-part. This part will execute before the report were filled.
Greets ReeBo
if you have detail data this could be done in the mdband using detailbandsdataset.recordcount property
and an [iif((detaildata1.dataset.recordcount = 0),true value,false value)] in the memo
rowcount property only applies to virtual datasets.
the dataset in the master data band. I'm still learning. It's possible that I could be using a detail band instead of the master.
It would be helpful if I could reference the master band from the header.
Thanks for your help.
Thanks to Reebo too. I'll try your suggestion later after doing other things. I'm not yet sure if I'll need to store the record count in a variable and then reference the variable in my code. or if I'll reference the record count as a "property" of the BDE query.
here is a tip when using group headers if you want to print
something in the group header that comes from values after the groupheader
you must make the report 2pass and gather the values in an array then subthe
array value in the second pass.
I've also tried getting the record count from the query. I still haven't worked out how to get Fast Reports to read the record count. I've tried storing the rowcount in a variable but haven't been able to get that variable to my code. I'll post my attempts later to
see if I can get it working that way.
I want to get it working both ways because I think it will help in the future.
I'm also trying another way. I placed one of the values from the query in the ReportTitle. Then a statement in a label on that band checks to see if it has a value.
The memo with the value reads
That is a value that stays constant on the report. That works.
In the label I've tried
and
In both cases, the label always reads 'something' even when the query does not return rows.
Is there a way to get the above to work?
Thanks for all the help.
If your data comes from a query, you should be able to do this in the main code area of the report:
The ClientNo and the two dates are inputs on the form.
I'm not sure what do with the other suggestions...
I'm sure they are good suggestions and would work if I put them in the right place and did a few other things. I'm just not sure how they apply to what I'm attempting. I will come back to them and try again to see if I can use them in the future.
Learning about 2pass on gordk's suggestion is what really helped.
Thanks to all.