Solved

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

Posted on 2007-11-30
10
2,099 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
 
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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 500 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Magic Software info 18 125
Working with hours 3 46
Convert a string into a TDateTime 5 50
Delphi: Connect to running MS Outlook 4 48
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

920 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now