Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Printing Records in Quick Report

Status
Not open for further replies.

dik

Technical User
Jul 18, 2001
217
0
16
MD
Is there an easy way of printing an array of records (records being a variable, not a database record) in a Quick Report Form?
 
??? dunno what your on about why not make them a database record, it will not take much room?
 
Try the QRlabel, it has a TCaption so the same procedures as with TLabels must be applicable.
Handy to put in a query criteria on your Report.

Regards S. van Els
SAvanEls@cq-link.sr
 
PiotrG:
With engineering programs, most of my data is in the form of Records or Classes (mostly floating point and the odd integer thrown in, also most arrays are dynamic) and it's really not convenient to convert them to databases. They load to and from files much quicker in present format.

Svanels:
I was looking for an easier way than QRLabels.

Thanks... you'd think that this would be common and easy for reports... haven't been able to find an easy way yet...

Dik
 
Try using a TQRStringBand it fetches lines ("records") from TStrings

-apw
 
I've done a similar thing in printing from a string grid with associated objects. The print fields are created when required in BuildReport and populated in NeedData.
It's rather a lot of code I'm afraid but I don't have time to tailor it just now. Post a reply if it's unfathomable and I'll cut it down as soon as I have time.
Code:
procedure TfmMain.BuildReport;
var
  Id, P, LeftPos: integer;
begin
  LeftPos := 0;
  for P := 0 to grdStk.ColCount-1 do
  begin
    Id := ColsId[P];
    if Visbl[Id] then
    begin
      PrtFld[P] := TQRLabel.Create(RptDetailBand); { if column is visible, create print field }
      PrtFld[P].Parent := RptDetailBand;           { must have a parent }
      PrtFld[P].Left := LeftPos;                   { location of the column }
      PrtFld[P].Width := grdStk.ColWidths[P];
      if RJust[Id] then
        PrtFld[P].Alignment := taRightJustify
      else
        PrtFld[P].Alignment := taLeftJustify;
      prtColHdr[P] := TQRLabel.Create(prtHeaderBand); { similarly create column header }
      prtColHdr[P].Parent := prtHeaderBand;
      prtColHdr[P].Top := prtHeaderBand.Height - prtColHdr[P].Height;
      prtColHdr[P].Left := LeftPos;
      prtColHdr[P].Width := grdStk.ColWidths[P];
      prtColHdr[P].Caption := grdStk.Cells[P,0];
      if RJust[Id] then
        PrtFld[P].Alignment := taRightJustify
      else
        PrtFld[P].Alignment := taLeftJustify;
      LeftPos := LeftPos + grdStk.ColWidths[P] +12;{ calculate next column position }
    end;
  end;
  RptGroupBand.Height := 0;                      { by default group headers not printed }
  prtTotalValue.Caption := Format('%m',[(grdStk.Objects[colSeq,grdStk.RowCount-1] as TGrpTitle).GrpValue]);
  prtHeading.Caption := 'STOCK VALUATION REPORT ' + FormatDateTime('dd mmm yyyy',ListDate);
  grdStk.Row := 0;
end;

procedure TfmMain.qrStkNeedData(Sender: TObject; var MoreData: Boolean);
var
  Id, P: integer;
begin
  with grdStk do
    if Row < RowCount-2 then
    begin
      MoreData := True;
      Row := Row +1;
      if not (Objects[colSeq,Row] as TGrpTitle).IsTitle then
        RptGroupBand.Height := 0
      else
      begin
        RptGroupBand.Height := 20;
        prtGrpDescrip.Caption := (Objects[colSeq,Row] as TGrpTitle).Caption;
        prtGrpValue.Caption := Format('%m',[(Objects[colSeq,Row] as TGrpTitle).GrpValue]);
        Row := Row +1;
      end;
      for Id := 1 to ColCount-1 do
      begin
        P := Posn[Id];
        if Visbl[Id] then
          PrtFld[P].Caption := Cells[P,Row];
      end
    end
    else
      MoreData := False;
end;
 
Thanks very much Dooda, I'll take a gander at it this evening. My day job isn't programming related.

Dik
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top