?
Solved

Delphi 7 :: Rave - Master Detail Report but do not print Detail for all Master records

Posted on 2007-11-30
10
Medium Priority
?
2,168 Views
Last Modified: 2013-11-22
HI Experts,

I have a strange scenario, or maybe not. :)

My report mast print a master row and also where a certain fields is flagged, print the detail row for that particular master row.

In my master table I have a field by name: "PrintDetail" of type smallint.
If this fields = 1 then in Rave the detailed band should be printed else it should not be printed.

Can you please help.

Thanks in advance.
0
Comment
Question by:Marius0188
[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
  • 4
  • 3
  • 3
10 Comments
 
LVL 13

Expert Comment

by:rfwoolf
ID: 20380562
Hi Marius

Yes you should set up a report and a dataconnection. Your one dataconnection will contect to your detail table. When you execute the report, your dataconnection will grab whatever fields are in that detail table.
I mean, you can even just use a filter if you like, which is what I do.
I say
Mytable.filtered := false;
Mytable.filter := 'MyField = ' + QuotedStr('77');
Mytable.filtered := true;
MyRaveReport.Execute;
MyTable.filtered := false;

For this purpose you can even use a TQuery if you prefer
0
 

Author Comment

by:Marius0188
ID: 20380665
Mmmh, I not sure if this is what I am looking for.

But close enough.

In the Rave report, some details records must be printed and others NOT.
Depending on a field value set in the Master table.

So somewhere in a OpPrinteDetailRecordsEvent()
I should be able to do something like this code:

If MasterTables.FieldByName('PrintDetail').AsInteger = 1 then
begin
  //Allow printing of detail records for this Master record because "PrintDetail" is flagged.
end
Else
begin
  AbortPrinting;
  //Do not print this detail records because the Master field "PrintDetail" is not flagged.
end;
0
 
LVL 13

Expert Comment

by:rfwoolf
ID: 20380737
Yeah, use a filter on a table or else a query on a Query
Do you know how to use DataConnections? (I think you have to know any way),
so just connect your Query or your Filtered Table to the dataconnection.

Let me know if you need help with the SQL code or filter, although the filter should be quite easy.

So maybe something like this:
If MasterTables.FieldByName('PrintDetail').AsInteger = 1 then
begin
   DetailTable.filtered := false;
   DetailTable.filter := 'KEYFIELD = 1';
   DetailTable.filter := True;
   MyRaveReport.Execute;
end
Else
begin
  showmessage('Sorry, there are no detail records to print!');
end;
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 13

Expert Comment

by:rfwoolf
ID: 20380745
The query version would be something like this:

So maybe something like this:
begin
   MyDetailQuery.SQL.clear;
   MyDetailQuery.SQL.Add('SELECT * FROM MyDetailTable WHERE ((MyKeyField) = ' + MasterTable.FieldByName('PrintDetail').value + ')';
   MyDetailQuery.Open;
   If MyDetailQuery.RecordCount > 0 then
   MyRaveReport.Execute
   else
   Showmessage('sorry theres no detail records');

Open in new window

0
 

Author Comment

by:Marius0188
ID: 20380800
Sorry, maybe I am not understanding.

But I need this to happen on the fly while the Rave report is generating.
Because as the rave report are populated, only then will I know when to print detail records or not.

So that is why I am looking for a way to do this in the Rave report designer on a Event.

To give you a example:
qADO.SQL.Text := 'SELECT M.ID, M.Description, M.PrintDetail, D.ID, D.Qty FROM tblMaster M LEFT OUTER JOIN tblDetail D ON D.ID = M.ID';

// The above query will have a mixed combination of PrintDetail in one result set. PrintDetail can be one
// for Master Record #1 while it can be off for Master Record #2, all in the same result set. So this is
// why I need do a check on an Event or something similar before printing the detail records in the Rave
// Report.

I noticed that in Rave Report, your components do have events as well, but I have never worked with those before and are not sure what language you code there. Maybe some help here can reveal a solutions.

Thanks again.
0
 
LVL 13

Expert Comment

by:rfwoolf
ID: 20380845
Okay sorry I don't really have experience with something like that. What i do know is that if you want to populate all your results in a Query and then execute the Rave Report that's one way.
Good luck
0
 
LVL 21

Accepted Solution

by:
developmentguru earned 2000 total points
ID: 20381680
I have a rave report that has several bands doing what you want to do.  In th first band in the OnBeforePrint method I do code like this for each band to determine if it will be visible.

  //Quantity Discount Band
  if dvSOItemsnDiscRateq.AsFloat = 0.00 then
    dbQuantityDiscount.Visible := false;
  else
    dbQuantityDiscount.Visible := true;
  end;

Substitute a comparison to your field and that should do it for you.  Let me know how it goes.
0
 
LVL 21

Expert Comment

by:developmentguru
ID: 20381686
Sorry, that should have read as "In the first DETAIL band".
0
 

Author Comment

by:Marius0188
ID: 20394015
HI developmentguru,

I have inserted this code as you suggested:

if dvPartsPrintBom.AsInteger = 0 then
  PartBoms.Visible := false;
else
   PartBoms.Visible := true;


But when clicking the compile button in rave report then I receive a error message:
Error #2 - [If] expected.

What is wrong?

Please help.
0
 
LVL 21

Expert Comment

by:developmentguru
ID: 20395183
One quick thing you can try is comparing
  .AsFloat = 0.00
      or
  .AsBoolean = True
This AsFloat is the comparison that is working for me, although my field is a floating point type.  There are some odities in the comparisons used in Rave.  I have noticed some around the comparisons with boolean values anyway.

  If that does not work, be sure to paste all of the text (in the gray areas above your code too, so I can tell where it has been placed.  Of course you would need to be sure that the component names match your components.  Here is the full code that is working in mine (gray areas included).  I placed it in my first detail data band.


-------------------------------------------------------------------------------------------------------------
{ Event for dbItemMain.OnBeforePrint }

function dbItemMain_OnBeforePrint(Self: TRaveDataBand);

begin
  //Quantity Discount
  if dvSOItemsnDiscRateq.AsFloat = 0.00 then
    dbQuantityDiscount.Visible := false;
  else
    dbQuantityDiscount.Visible := true;
  end;

  //System Discount
  if dvSOItemsnDiscRatsd.AsFloat = 0.00 then
    dbSystemDiscount.Visible := false;
  else
    dbSystemDiscount.Visible := true;
  end;

  //Special Discount
  if dvSOItemsnDiscRates.AsFloat = 0.00 then
    dbSpecialDiscount.Visible := false;
  else
    dbSpecialDiscount.Visible := true;
  end;

  //Warranty Discount
  if dvSOItemsnDiscRatew.AsFloat = 0.00 then
    dbWarrantyDiscount.Visible := false;
  else
    dbWarrantyDiscount.Visible := true;
  end;

  //Dealer Discount
  if dvSOItemsnDiscRated.AsFloat = 0.00 then
    dbDealerDiscount.Visible := false;
  else
    dbDealerDiscount.Visible := true;
  end;
end OnBeforePrint;
-------------------------------------------------------------------------------------------------------------
If none of this helps... what version of Rave are you using?
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

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…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

765 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