James
Never apologise for providing assistance - it's always useful!
 
Nello
 
Your comments have given me cause to revisit my basic design - and as usual, you have hit the nail on the head.  My problems stem from an earlier lack of understanding of how Delphi works and I had (un-necessarily) created several TQuery's (each of which I was trying to pass to the report) when one would have done.  (I can see the eyes rolling!).
 
Have now fixed it. 
 
Thanks everyone for your help.
 
Mark
----- Original Message -----
From: James Low
Sent: Wednesday, May 02, 2001 3:20 PM
Subject: RE: [DUG]: Passing DataSet to Quick Report

...and reading the original enquiry! Sorry Mark.
-----Original Message-----
From: Nello Sestini [mailto:[EMAIL PROTECTED]]
Sent: 2 May 2001 18:40
To: Multiple recipients of list delphi
Subject: Re: [DUG]: Passing DataSet to Quick Report

 
Maybe this is one case where setting a global variable IS appropriate?!
 
FWIW i think having the dataset "outside"  sort of violates
the principle James argued earlier that everything should be
visible within the report unit.    Because otherwise the
function of the report is dependant on "stuff you can't see"
like the details of the query and field definitions of the
outside dataset.
 
But if you insist on doing that - there are some ways
to pass the thing in.   You don't have to resort to globals
the way a VB programmer probably would
 
You can:
 
1.  Make the dataset a property of the form containing
    the quickreport component and set that property
    after you create the form but before you show it.
 
2.  Make the dataset a parameter of the constructor
    of the form and have the constructor use it to set
    things up when you create the form (or at least
    save it in a private field)
 
3.  If the form is modeless and you want to be able
    to change the dataset without destroying/recreating
    the form you can add a method to the form
    and include the dataset as a parameter to the method.
 
4.  you can include a procedure in the same unit as the
    form containing the quickreport (but not a method
    of that form) that creates an instance of the form
    and accepts the dataset as a parameter.    Since
    it's in the same unit, it will have access to all
    the forms private fields just as a method would
    and could set a private field (much as a constructor
    would)
 
5.  If you won't be invoking the QR from lots of different
    places, consider putting the QR component on the
    SAME FORM as the unit that will invoke it - but "off camera"
    (i.e. beyond the borders of the window so it doesn't
    display).    This won't inhibit the "preview" function
    at all - it will still show.   And it eliminates
    the need to "pass" a lot of information between
    forms when you generate the report.
 
I'd probably favour 1 or 5 - but not sure there's a
compelling case to be made for preferring any one of these
over another.
 
-ns
 
 
 

Reply via email to