[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
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,202 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
  • 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

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…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Suggested Courses
Course of the Month17 days, 16 hours left to enroll

831 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