James
Thanks for the pointers. 
You are right. It IS better to assign the dataset from within the report.  Much more straightforward.
There are reasons why it is not convenient to put the query on the report (not sure how valid they are, though!)
So my intention is to set the dataset within the report - like:
 
Case RepNo of
    1: Dataset := Query1;
    2: Dataset := Query2;
etc.
 
So now the question may be simpler:
How do I pass the parameter RepNo to the report?
 
Mark
----- Original Message -----
From: James Low
Sent: Tuesday, May 01, 2001 9:09 PM
Subject: RE: [DUG]: Passing DataSet to Quick Report

No ---  was assuming the quick report wrapper had a dataset property and that that was what you were trying to set - in which case you need to ensure the dataset belongs to the same form .. or is visible to the form (ie uses the unit the dataset is in) that contains the report. I don't have Delphi in front of me here - so will have a look later if noone else chirps up.... but ...
 
I might have my from (BCInv)  have a public method (ie SetReportQuery(myDatset : TQuery)) that after you have created the query you can then use to associate this query with that report ( ie BCInv.Report1.Dataset := myDataset)...or on the reports forms constructor (override it) pass in a query object.
 
Or, simpler still, just pop the query component on the same form as the report. Create the form as you show etc.
 
But not having used report smith, and picking up on the newbie bit, I fealt you might be a bit lost in the woods.
-----Original Message-----
From: Mark Howard [mailto:[EMAIL PROTECTED]]
Sent: 3 May 2001 10:36
To: Multiple recipients of list delphi
Subject: Re: [DUG]: Passing DataSet to Quick Report

OK
Thanks everyone on the comments on Globals vs parameters.  Generally 'no contest' it seems.
 
James
Do you know how I pass the Dataset to a quick report?
In my example below, where do I pass the dataset?
and how do I declare the report so that it is expecting a dataset to be passed?
Mark
 
----- Original Message -----
From: James Low
Sent: Tuesday, May 01, 2001 8:21 PM
Subject: RE: [DUG]: Passing DataSet to Quick Report

Possibly an answer to two question in one:
 
First, I assume you shouldnt pass the Dataset name, pass the Dataset object (TDataset) - which is just a pointer anyway.
 
Regarding the variables thing the ideal is to write code that is self documenting and as self contained as possible. A procedure that depends on a global variable to operate correctly requires someone to explain that fact, and is less portable (what say that global variable has a different name in another program?). That said, class methods often rely on form level variables - but they are always part of the class that has these variables so, again, things are self contained.
 
Avoid using global variables, but not too an extreme. Often you'll want to, say, remember the state of a grid (edited/ not edited) and a procedure will need to chck out this global variable to, say, disable/enable buttons ... thats fair enough. But make sure its easy to follow - the variables are clearly named etc.

[James Low]  -----Original Message-----
From: Mark Howard [mailto:[EMAIL PROTECTED]]
Sent: 3 May 2001 09:51
To: Multiple recipients of list delphi
Subject: [DUG]: Passing DataSet to Quick Report

Hi All
 
I would like to pass a Dataset name to a Quick Report but am not sure how to go about this.
 
I have something like:
 
with QueryDataModule.Query1 do
    begin
      Close;
      DatabaseName := MainForm.DatabaseName;
      SQL.Clear;
      SQL.Add('Select stuff from Tables);
      Open;
    end;
    Application.CreateForm(TBCInv, BCInv);
    if OutMode = 'Screen' then BCInv.Report.Preview
          else BCInv.Report.Print;
 
What I want to do is pass QueryDataModule.Query1 to BCInv on this occaision
and some other dataset to it on another occaision.
 
Has anyone some code snippets that demonstrate this?
 
TIA
 
Mark
 

Reply via email to