Ir para conteúdo
Fórum Script Brasil
  • 0

Respondam Qdo Puder (RESOLVIDO ENFIM)


Alessandro

Pergunta

Serei breve...

Tenho um Form chamado fmGerarRelAt :

Clique aqui para ver o Form Gerar Relatório

Preciso que somente os código selecionados apareçam no relatório, e para isso eu coloquei este código no evento OnCreate do Form do Relatório :

procedure TfmRelAt.FormCreate(Sender: TObject);
var Total : Integer;
begin
  Total := 0;
  modProjeto.tbCadAt.First;  
  while not modProjeto.tbCadAt.Eof do 
    begin
     query1.active := false;
     query1.sql.clear;
     query1.sql.add('SELECT Quantidade FROM dbCadAt.db WHERE CodPart = "'+fmGerarRelAt.Lista2.Items.Text+'"');
     query1.active:= true;
     Total := modProjeto.tbCadAtQuantidade.Value + Total;
     modProjeto.tbCadAt.Next;
    end;
     qrLabel5.Caption := inttostr(Total);
end;

fmGerarRelAt : é o nome do Form do Relatório

Lista2 : é o nome da minha ListBox

O problema é que mesmo com esse código, o sistema compila mas acaba trazendo todos os códigos como a vocês podem ver na figura abaixo :

Clique aqui para ver como sai o Relatório

Se alguém tiver alguma sugestão postaí para eu tentar....valeu smile.gif

Link para o comentário
Compartilhar em outros sites

  • Respostas 93
  • Created
  • Última resposta

Top Posters For This Question

Posts Recomendados

  • 0

Unit Principal

unit U_Principal;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, Menus, ComCtrls, ExtCtrls, Buttons, StdCtrls, DBCtrls;

type
  TfmPrincipal = class(TForm)
    MainMenu1: TMainMenu;
    Cadastro1: TMenuItem;
    CadastrodeAT1: TMenuItem;
    CadastrodeUsurio1: TMenuItem;
    Atendimento1: TMenuItem;
    Script1: TMenuItem;
    Relatrios1: TMenuItem;
    Usurios1: TMenuItem;
    Assistm1: TMenuItem;
    Listas1: TMenuItem;
    OSCancelada1: TMenuItem;
    InsumosSolicitados1: TMenuItem;
    Ajuda1: TMenuItem;
    Sair1: TMenuItem;
    StatusBar1: TStatusBar;
    Timer1: TTimer;
    SpeedButton1: TSpeedButton;
    SpeedButton2: TSpeedButton;
    SpeedButton3: TSpeedButton;
    SpeedButton4: TSpeedButton;
    SpeedButton5: TSpeedButton;
    SpeedButton6: TSpeedButton;
    procedure FormCreate(Sender: TObject);
    procedure Sair1Click(Sender: TObject);
    procedure CadastrodeAT1Click(Sender: TObject);
    procedure CadastrodeUsurio1Click(Sender: TObject);
    procedure Usurios1Click(Sender: TObject);
    procedure Assistm1Click(Sender: TObject);
    procedure Timer1Timer(Sender: TObject);
    procedure Script1Click(Sender: TObject);
    procedure OSCancelada1Click(Sender: TObject);
    procedure SpeedButton1Click(Sender: TObject);
    procedure SpeedButton3Click(Sender: TObject);
    procedure SpeedButton2Click(Sender: TObject);
    procedure SpeedButton4Click(Sender: TObject);
    procedure InsumosSolicitados1Click(Sender: TObject);
    procedure SpeedButton5Click(Sender: TObject);
    procedure SpeedButton6Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  fmPrincipal: TfmPrincipal;

implementation

uses U_CadUsu, U_CadAt, U_RelAt, U_RelUsu, U_CadOsCancel, U_Suporte,
  U_GerarRelAt;

{$R *.dfm}

procedure TfmPrincipal.FormCreate(Sender: TObject);
var Data: TDateTime;
begin
  Data := Now;
  StatusBar1.Panels[1].Text := FormatDateTime('dddd," "dd" de "mmmm" de "yyyy',Data);
  WindowState := wsMaximized;
  SetWindowLong(Application.Handle,GWL_EXSTYLE,
  GetWindowLong(Application.Handle, GWL_EXSTYLE)
  or WS_EX_TOOLWINDOW and not WS_EX_APPWINDOW);
end;

procedure TfmPrincipal.Sair1Click(Sender: TObject);
begin
 if MessageDlg('Deseja sair do Sistema ?',mtConfirmation,[mbyes,mbno],0) = mrYes then
   begin
     Application.Terminate;
   end
end;

procedure TfmPrincipal.CadastrodeAT1Click(Sender: TObject);
begin
  fmCadAt := tfmCadAt.create(application);
  fmCadAt.showmodal; // abre o formulário no modo moldal para não perder o foco
  fmCadAt.Release;  //apaga form da memória quando o mesmo for fechado
end;

procedure TfmPrincipal.CadastrodeUsurio1Click(Sender: TObject);
begin
fmCadUsu := tfmCadUsu.create(application);
  fmCadUsu.showmodal; // abre o formulário no modo moldal para não perder o foco
  fmCadUsu.Release;  //apaga form da memória quando o mesmo for fechado
end;

procedure TfmPrincipal.Usurios1Click(Sender: TObject);
begin
    fmGerarRelAt := tfmGerarRelAt.Create(application);
    fmGerarRelAt.ShowModal;
    fmGerarRelAt.Release;
end;

procedure TfmPrincipal.Assistm1Click(Sender: TObject);
begin
  fmRelUsu := tfmRelUsu.create(application);
  fmRelUsu.QuickRep1.Preview; 
  fmRelUsu.Release;  //apaga form da memória quando o mesmo for fechado
end;

procedure TfmPrincipal.Timer1Timer(Sender: TObject);
begin
StatusBar1.Panels[2].Text := timetostr(time);
end;

procedure TfmPrincipal.Script1Click(Sender: TObject);
begin
WinExec('c:\Projeto\Script.exe', sw_normal);
WindowState :=  wsMinimized;
end;

procedure TfmPrincipal.OSCancelada1Click(Sender: TObject);
begin
  fmCadOsCancel := tfmCadOsCancel.create(application);
  fmCadOsCancel.showmodal; // abre o formulário no modo moldal para não perder o foco
  fmCadOsCancel.Release;  //apaga form da memória quando o mesmo for fechado
end;

procedure TfmPrincipal.SpeedButton1Click(Sender: TObject);
begin
  fmCadAt := tfmCadAt.create(application);
  fmCadAt.showmodal; // abre o formulário no modo moldal para não perder o foco
  fmCadAt.Release;  //apaga form da memória quando o mesmo for fechado
end;

procedure TfmPrincipal.SpeedButton3Click(Sender: TObject);
begin
  fmCadOsCancel := tfmCadOsCancel.create(application);
  fmCadOsCancel.showmodal; // abre o formulário no modo moldal para não perder o foco
  fmCadOsCancel.Release;  //apaga form da memória quando o mesmo for fechado
end;

procedure TfmPrincipal.SpeedButton2Click(Sender: TObject);
begin
fmCadUsu := tfmCadUsu.create(application);
  fmCadUsu.showmodal; // abre o formulário no modo moldal para não perder o foco
  fmCadUsu.Release;  //apaga form da memória quando o mesmo for fechado
end;

procedure TfmPrincipal.SpeedButton4Click(Sender: TObject);
begin
  fmGerarRelAt := tfmGerarRelAt.create(application);
  fmGerarRelAt.showModal;
  fmGerarRelAt.Release;  //apaga form da memória quando o mesmo for fechado
end;

procedure TfmPrincipal.InsumosSolicitados1Click(Sender: TObject);
begin
fmSuporte := tfmSuporte.create(application);
fmSuporte.showmodal;
fmSuporte.Release;
end;

procedure TfmPrincipal.SpeedButton5Click(Sender: TObject);
begin
fmSuporte := tfmSuporte.create(application);
fmSuporte.showmodal;
fmSuporte.Release;
end;

procedure TfmPrincipal.SpeedButton6Click(Sender: TObject);
begin
 if MessageDlg('Deseja sair do Sistema ?',mtConfirmation,[mbyes,mbno],0) = mrYes then
   begin
     Application.Terminate;
   end
end;

end.
Unit do GerarRelAt
unit U_GerarRelAt;

interface

uses 
  Windows, Messages, SysUtils, Classes, Graphics, Forms, Dialogs, Controls, StdCtrls, 
  Buttons, DB, DBTables, Grids, DBGrids;

type
  TfmGerarRelAt = class(TForm)
    Lista1: TListBox;
    Lista2: TListBox;
    SrcLabel: TLabel;
    DstLabel: TLabel;
    IncludeBtn: TSpeedButton;
    IncAllBtn: TSpeedButton;
    ExcludeBtn: TSpeedButton;
    ExAllBtn: TSpeedButton;
    SpeedButton1: TSpeedButton;
    SpeedButton2: TSpeedButton;
    Label1: TLabel;
    DBGrid1: TDBGrid;
    DataSource1: TDataSource;
    Query1: TQuery;
    procedure IncludeBtnClick(Sender: TObject);
    procedure ExcludeBtnClick(Sender: TObject);
    procedure IncAllBtnClick(Sender: TObject);
    procedure ExcAllBtnClick(Sender: TObject);
    procedure btnCancelClick(Sender: TObject);
    procedure btnGerarClick(Sender: TObject);
    procedure SpeedButton1Click(Sender: TObject);
    procedure SpeedButton2Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
    procedure MoveSelected(List: TCustomListBox; Items: TStrings);
    procedure SetItem(List: TListBox; Index: Integer);
    function GetFirstSelection(List: TCustomListBox): Integer;
    procedure SetButtons;
  end;

var
  fmGerarRelAt: TfmGerarRelAt;

implementation

uses U_RelAt, dataProjeto, U_CadAt;

{$R *.dfm}

procedure TfmGerarRelAt.IncludeBtnClick(Sender: TObject);
var
  Index: Integer;
begin
  Index := GetFirstSelection(Lista1);
  MoveSelected(Lista1, Lista2.Items);
  SetItem(Lista1, Index);
end;

procedure TfmGerarRelAt.ExcludeBtnClick(Sender: TObject);
var
  Index: Integer;
begin
  Index := GetFirstSelection(Lista2);
  MoveSelected(Lista2, Lista1.Items);
  SetItem(Lista2, Index);
end;

procedure TfmGerarRelAt.IncAllBtnClick(Sender: TObject);
var
  I: Integer;
begin
  for I := 0 to Lista1.Items.Count - 1 do
    Lista2.Items.AddObject(Lista1.Items[I],
      Lista1.Items.Objects[I]);
  Lista1.Items.Clear;
  SetItem(Lista1, 0);
end;

procedure TfmGerarRelAt.ExcAllBtnClick(Sender: TObject);
var
  I: Integer;
begin
  for I := 0 to Lista2.Items.Count - 1 do
    Lista1.Items.AddObject(Lista2.Items[I], Lista2.Items.Objects[I]);
  Lista2.Items.Clear;
  SetItem(Lista2, 0);
end;

procedure TfmGerarRelAt.MoveSelected(List: TCustomListBox; Items: TStrings);
var
  I: Integer;
begin
  for I := List.Items.Count - 1 downto 0 do
    if List.Selected[I] then
    begin
      Items.AddObject(List.Items[I], List.Items.Objects[I]);
      List.Items.Delete(I);
    end;
end;

procedure TfmGerarRelAt.SetButtons;
var
  SrcEmpty, DstEmpty: Boolean;
begin
  SrcEmpty := Lista1.Items.Count = 0;
  DstEmpty := Lista2.Items.Count = 0;
  IncludeBtn.Enabled := not SrcEmpty;
  IncAllBtn.Enabled := not SrcEmpty;
  ExcludeBtn.Enabled := not DstEmpty;
  ExAllBtn.Enabled := not DstEmpty;
end;

function TfmGerarRelAt.GetFirstSelection(List: TCustomListBox): Integer;
begin
  for Result := 0 to List.Items.Count - 1 do
    if List.Selected[Result] then Exit;
  Result := LB_ERR;
end;

procedure TfmGerarRelAt.SetItem(List: TListBox; Index: Integer);
var
  MaxIndex: Integer;
begin
  with List do
  begin
    SetFocus;
    MaxIndex := List.Items.Count - 1;
    if Index = LB_ERR then Index := 0
    else if Index > MaxIndex then Index := MaxIndex;
    Selected[Index] := True;
  end;
  SetButtons;
end;

procedure TfmGerarRelAt.btnCancelClick(Sender: TObject);
begin
fmGerarRelAt.Close;
end;

procedure TfmGerarRelAt.btnGerarClick(Sender: TObject);
var i:Integer; sWhe:String;
begin
  Query1.Close;

  sWhe := 'Select * From dbCadAt.db ';

  for i := 0 to Lista2.Items.Count-1 do
  begin
    if Lista2.Items.Count > 10 then
    begin
      MessageDLG('Você ultrapassou a capacidade de itens selecionados!',mtWarning,[mbok],0);
      abort;
    end
    else begin
      if i = 0 then
        begin
          sWhe := sWhe + 'Where (CodPart = :P' + IntToStr(i) +')'
        end
       else begin
        sWhe := sWhe + ' or (CodPart = :P' + IntToStr(i) + ')';
       end;
    end;
  end;
  Query1.SQL.Text := sWhe;

  ShowMessage(sWhe); //<- vamu ver agora...
  modProjeto.tbCadAt.First;

  for i := 0 to Lista2.Items.Count-1 do
   begin
    Query1.ParamByName('P'+IntToStr(i)).asString := Lista2.Items[i];
   end;
    Query1.Open;
    fmRelAt := tfmRelAt.Create(application);
    fmRelAt.QuickRep1.Preview;
    fmRelAt.Release;
end;



procedure TfmGerarRelAt.SpeedButton1Click(Sender: TObject);
var i:Integer; sWhe:String;
begin
  Query1.Close;

  sWhe := 'Select CodPart,NomeFant,Quantidade From dbCadAt.db ';

  for i := 0 to Lista2.Items.Count-1 do
  begin
    if Lista2.Items.Count > 10 then
    begin
      MessageDLG('Você ultrapassou a capacidade de itens selecionados!',mtWarning,[mbok],0);
      abort;
    end
    else begin
      if i = 0 then
        begin
          sWhe := sWhe + 'Where (CodPart = :P' + IntToStr(i) +')'
        end
       else begin
        sWhe := sWhe + ' or (CodPart = :P' + IntToStr(i) + ')';
       end;
    end;
  end;
  Query1.SQL.Text := sWhe;

  ShowMessage(sWhe); //<- vamu ver agora...

  for i := 0 to Lista2.Items.Count-1 do
   begin
    Query1.ParamByName('P'+IntToStr(i)).asString := Lista2.Items[i];
   end;

    Query1.Open;
    fmRelAt := tfmRelAt.Create(application);
    fmRelAt.QuickRep1.Preview;
    fmRelAt.Release;

end;

procedure TfmGerarRelAt.SpeedButton2Click(Sender: TObject);
begin
fmGerarRelAt.Close;
end;

end.
Unit do Relatório
unit U_RelAt;

interface

uses
  SysUtils, Windows, Messages, Classes, Graphics, Controls,
  StdCtrls, ExtCtrls, Forms, QuickRpt, QRCtrls, DB, DBTables, Buttons;

type
  TfmRelAt = class(TForm)
    QuickRep1: TQuickRep;
    PageFooterBand1: TQRBand;
    QRExpr1: TQRExpr;
    ColumnHeaderBand1: TQRBand;
    DetailBand1: TQRBand;
    QRLabel1: TQRLabel;
    QRExpr2: TQRExpr;
    QRLabel2: TQRLabel;
    QRExpr3: TQRExpr;
    QRLabel3: TQRLabel;
    QRExpr4: TQRExpr;
    Table1: TTable;
    TitleBand1: TQRBand;
    QRLabel4: TQRLabel;
    QRLabel5: TQRLabel;
    QRLabel6: TQRLabel;
    QRExpr5: TQRExpr;
    Query1: TQuery;
    DataSource1: TDataSource;
    procedure SpeedButton1Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
  private
  end;

var
  fmRelAt: TfmRelAt;

implementation

uses dataProjeto, U_GerarRelAt, U_CadAt;

{$R *.DFM}

procedure TfmRelAt.SpeedButton1Click(Sender: TObject);
begin
modProjeto.tbCadUsu.First;

QrLabel5.Caption := 'Teste'
end;

procedure TfmRelAt.FormCreate(Sender: TObject);
var i,Total:Integer;
begin
  Total := 0;
  Query1.Close;
  Query1.SQL.Text := 'Select Quantidade From dbCadAt.db Where CodPart = :cod';
   for i := 0 to fmGerarRelAt.Lista2.Items.Count-1 do
     begin
      Query1.ParamByName('cod').asString := fmGerarRelAt.Lista2.Items[i];
      Query1.Open;
      Total := Total + Query1.FieldByName('Quantidade').asInteger;
      Query1.Close;
    end;
   qrLabel5.Caption := IntToStr(Total);
end;

end.

Valeu... smile.gif

Link para o comentário
Compartilhar em outros sites

  • 0

Bom...vamos ver se entendi....

No QuickRep1, a propriedade DataSet está apontando para :

fmGerarRelAt.Query1

Era isso que você queria saber ?! wink.gif

Ahh, consegui o View as Text do Relatório....ajuda ?!?!

object fmRelAt: TfmRelAt
  Left = 210
  Top = 163
  Width = 681
  Height = 493
  Caption = 'Relatório de Ligações'
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'MS Sans Serif'
  Font.Style = []
  OldCreateOrder = False
  Scaled = False
  OnCreate = FormCreate
  PixelsPerInch = 96
  TextHeight = 13
  object QuickRep1: TQuickRep
    Left = 0
    Top = 0
    Width = 794
    Height = 1123
    Frame.Color = clBlack
    Frame.DrawTop = False
    Frame.DrawBottom = False
    Frame.DrawLeft = False
    Frame.DrawRight = False
    DataSet = fmGerarRelAt.Query1
    Font.Charset = DEFAULT_CHARSET
    Font.Color = clWindowText
    Font.Height = -13
    Font.Name = 'Verdana'
    Font.Style = []
    Functions.Strings = (
      'PAGENUMBER'
      'COLUMNNUMBER'
      'REPORTTITLE')
    Functions.DATA = (
      '0'
      '0'
      '''''')
    Options = [FirstPageHeader, LastPageFooter]
    Page.Columns = 1
    Page.Orientation = poPortrait
    Page.PaperSize = A4
    Page.Values = (
      100
      2970
      100
      2100
      100
      100
      0)
    PrinterSettings.Copies = 1
    PrinterSettings.Duplex = False
    PrinterSettings.FirstPage = 0
    PrinterSettings.LastPage = 0
    PrinterSettings.OutputBin = Auto
    PrintIfEmpty = True
    SnapToGrid = True
    Units = MM
    Zoom = 100
    object PageFooterBand1: TQRBand
      Left = 38
      Top = 122
      Width = 718
      Height = 22
      Frame.Color = clBlack
      Frame.DrawTop = False
      Frame.DrawBottom = False
      Frame.DrawLeft = False
      Frame.DrawRight = False
      AlignToBottom = False
      Color = clWhite
      ForceNewColumn = False
      ForceNewPage = False
      Size.Values = (
        58.2083333333333
        1899.70833333333)
      BandType = rbPageFooter
      object QRExpr1: TQRExpr
        Left = 574
        Top = 0
        Width = 144
        Height = 17
        Frame.Color = clBlack
        Frame.DrawTop = False
        Frame.DrawBottom = False
        Frame.DrawLeft = False
        Frame.DrawRight = False
        Size.Values = (
          44.9791666666667
          1518.70833333333
          0
          381)
        Alignment = taRightJustify
        AlignToBand = True
        AutoSize = True
        AutoStretch = False
        Color = clWhite
        ResetAfterPrint = False
        Transparent = False
        WordWrap = True
        Expression = '''Page '' + PageNumber'
        FontSize = 10
      end
    end
    object ColumnHeaderBand1: TQRBand
      Left = 38
      Top = 78
      Width = 718
      Height = 22
      Frame.Color = clBlack
      Frame.DrawTop = False
      Frame.DrawBottom = False
      Frame.DrawLeft = False
      Frame.DrawRight = False
      AlignToBottom = False
      Color = clWhite
      ForceNewColumn = False
      ForceNewPage = False
      Size.Values = (
        58.2083333333333
        1899.70833333333)
      BandType = rbColumnHeader
      object QRLabel1: TQRLabel
        Left = 41
        Top = 0
        Width = 112
        Height = 17
        Frame.Color = clBlack
        Frame.DrawTop = False
        Frame.DrawBottom = True
        Frame.DrawLeft = False
        Frame.DrawRight = False
        Size.Values = (
          44.9791666666667
          108.479166666667
          0
          296.333333333333)
        Alignment = taLeftJustify
        AlignToBand = False
        AutoSize = False
        AutoStretch = False
        Caption = 'Código Partner'
        Color = clWhite
        Font.Charset = DEFAULT_CHARSET
        Font.Color = clWindowText
        Font.Height = -13
        Font.Name = 'Verdana'
        Font.Style = [fsBold]
        ParentFont = False
        Transparent = False
        WordWrap = True
        FontSize = 10
      end
      object QRLabel2: TQRLabel
        Left = 182
        Top = 0
        Width = 107
        Height = 17
        Frame.Color = clBlack
        Frame.DrawTop = False
        Frame.DrawBottom = True
        Frame.DrawLeft = False
        Frame.DrawRight = False
        Size.Values = (
          44.9791666666667
          481.541666666667
          0
          283.104166666667)
        Alignment = taLeftJustify
        AlignToBand = False
        AutoSize = False
        AutoStretch = False
        Caption = 'Nome Fantasia'
        Color = clWhite
        Font.Charset = DEFAULT_CHARSET
        Font.Color = clWindowText
        Font.Height = -13
        Font.Name = 'Verdana'
        Font.Style = [fsBold]
        ParentFont = False
        Transparent = False
        WordWrap = True
        FontSize = 10
      end
      object QRLabel3: TQRLabel
        Left = 443
        Top = 0
        Width = 86
        Height = 17
        Frame.Color = clBlack
        Frame.DrawTop = False
        Frame.DrawBottom = True
        Frame.DrawLeft = False
        Frame.DrawRight = False
        Size.Values = (
          44.9791666666667
          1172.10416666667
          0
          227.541666666667)
        Alignment = taLeftJustify
        AlignToBand = False
        AutoSize = False
        AutoStretch = False
        Caption = 'Ligações'
        Color = clWhite
        Font.Charset = DEFAULT_CHARSET
        Font.Color = clWindowText
        Font.Height = -13
        Font.Name = 'Verdana'
        Font.Style = [fsBold]
        ParentFont = False
        Transparent = False
        WordWrap = True
        FontSize = 10
      end
      object QRLabel5: TQRLabel
        Left = 640
        Top = 0
        Width = 61
        Height = 17
        Frame.Color = clBlack
        Frame.DrawTop = False
        Frame.DrawBottom = False
        Frame.DrawLeft = False
        Frame.DrawRight = False
        Size.Values = (
          44.9791666666667
          1693.33333333333
          0
          161.395833333333)
        Alignment = taLeftJustify
        AlignToBand = False
        AutoSize = True
        AutoStretch = False
        Caption = 'QRLabel5'
        Color = clWhite
        Transparent = False
        WordWrap = True
        FontSize = 10
      end
      object QRLabel6: TQRLabel
        Left = 587
        Top = 0
        Width = 46
        Height = 17
        Frame.Color = clBlack
        Frame.DrawTop = False
        Frame.DrawBottom = True
        Frame.DrawLeft = False
        Frame.DrawRight = False
        Size.Values = (
          44.9791666666667
          1553.10416666667
          0
          121.708333333333)
        Alignment = taLeftJustify
        AlignToBand = False
        AutoSize = False
        AutoStretch = False
        Caption = 'Total'
        Color = clWhite
        Font.Charset = DEFAULT_CHARSET
        Font.Color = clWindowText
        Font.Height = -13
        Font.Name = 'Verdana'
        Font.Style = [fsBold]
        ParentFont = False
        Transparent = False
        WordWrap = True
        FontSize = 10
      end
    end
    object DetailBand1: TQRBand
      Left = 38
      Top = 100
      Width = 718
      Height = 22
      Frame.Color = clBlack
      Frame.DrawTop = False
      Frame.DrawBottom = False
      Frame.DrawLeft = False
      Frame.DrawRight = False
      AlignToBottom = False
      Color = clWhite
      ForceNewColumn = False
      ForceNewPage = False
      Size.Values = (
        58.2083333333333
        1899.70833333333)
      BandType = rbDetail
      object QRExpr2: TQRExpr
        Left = 41
        Top = 0
        Width = 64
        Height = 17
        Frame.Color = clBlack
        Frame.DrawTop = False
        Frame.DrawBottom = False
        Frame.DrawLeft = False
        Frame.DrawRight = False
        Size.Values = (
          44.9791666666667
          108.479166666667
          0
          169.333333333333)
        Alignment = taLeftJustify
        AlignToBand = False
        AutoSize = False
        AutoStretch = False
        Color = clWhite
        ResetAfterPrint = False
        Transparent = False
        WordWrap = True
        Expression = '[CodPart]'
        FontSize = 10
      end
      object QRExpr3: TQRExpr
        Left = 182
        Top = 0
        Width = 259
        Height = 17
        Frame.Color = clBlack
        Frame.DrawTop = False
        Frame.DrawBottom = False
        Frame.DrawLeft = False
        Frame.DrawRight = False
        Size.Values = (
          44.9791666666667
          481.541666666667
          0
          685.270833333333)
        Alignment = taLeftJustify
        AlignToBand = False
        AutoSize = False
        AutoStretch = False
        Color = clWhite
        ResetAfterPrint = False
        Transparent = False
        WordWrap = True
        Expression = '[NomeFant]'
        FontSize = 10
      end
      object QRExpr4: TQRExpr
        Left = 443
        Top = 0
        Width = 86
        Height = 17
        Frame.Color = clBlack
        Frame.DrawTop = False
        Frame.DrawBottom = False
        Frame.DrawLeft = False
        Frame.DrawRight = False
        Size.Values = (
          44.9791666666667
          1172.10416666667
          0
          227.541666666667)
        Alignment = taRightJustify
        AlignToBand = False
        AutoSize = False
        AutoStretch = False
        Color = clWhite
        ResetAfterPrint = False
        Transparent = False
        WordWrap = True
        Expression = '[Quantidade]'
        FontSize = 10
      end
      object QRExpr5: TQRExpr
        Left = 0
        Top = 0
        Width = 47
        Height = 17
        Frame.Color = clBlack
        Frame.DrawTop = False
        Frame.DrawBottom = False
        Frame.DrawLeft = False
        Frame.DrawRight = False
        Size.Values = (
          44.9791666666667
          0
          0
          124.354166666667)
        Alignment = taLeftJustify
        AlignToBand = False
        AutoSize = True
        AutoStretch = False
        Color = clWhite
        ResetAfterPrint = False
        Transparent = False
        WordWrap = True
        Expression = 'COUNT'
        FontSize = 10
      end
    end
    object TitleBand1: TQRBand
      Left = 38
      Top = 38
      Width = 718
      Height = 40
      Frame.Color = clBlack
      Frame.DrawTop = False
      Frame.DrawBottom = False
      Frame.DrawLeft = False
      Frame.DrawRight = False
      AlignToBottom = False
      Color = clWhite
      ForceNewColumn = False
      ForceNewPage = False
      Size.Values = (
        105.833333333333
        1899.70833333333)
      BandType = rbTitle
      object QRLabel4: TQRLabel
        Left = 112
        Top = 8
        Width = 506
        Height = 26
        Frame.Color = clBlack
        Frame.DrawTop = False
        Frame.DrawBottom = False
        Frame.DrawLeft = False
        Frame.DrawRight = False
        Size.Values = (
          68.7916666666667
          296.333333333333
          21.1666666666667
          1338.79166666667)
        Alignment = taLeftJustify
        AlignToBand = False
        AutoSize = True
        AutoStretch = False
        Caption = 'Relatório de Ligações das Assistências Técnicas'
        Color = clWhite
        Font.Charset = DEFAULT_CHARSET
        Font.Color = clWindowText
        Font.Height = -21
        Font.Name = 'Verdana'
        Font.Style = []
        ParentFont = False
        Transparent = False
        WordWrap = True
        FontSize = 16
      end
    end
  end
  object Table1: TTable
    Active = True
    DatabaseName = 'Projeto'
    TableName = 'dbCadAt.DB'
    Left = 7
    Top = 8
  end
  object Query1: TQuery
    DatabaseName = 'Projeto'
    Left = 48
    Top = 8
  end
  object DataSource1: TDataSource
    DataSet = Query1
    Left = 88
    Top = 8
  end
end

Link para o comentário
Compartilhar em outros sites

  • 0

Lá no final eu chamo assim :

fmRelAt := tfmRelAt.Create(application);

fmRelAt.QuickRep1.Preview;

fmRelAt.Release

procedure TfmGerarRelAt.SpeedButton1Click(Sender: TObject);
var i:Integer; sWhe:String;
begin
  Query1.Close;

  sWhe := 'Select CodPart,NomeFant,Quantidade From dbCadAt.db ';

  for i := 0 to Lista2.Items.Count-1 do
  begin
    if Lista2.Items.Count > 10 then
    begin
      MessageDLG('Você ultrapassou a capacidade de itens selecionados!',mtWarning,[mbok],0);
      abort;
    end
    else begin
      if i = 0 then
        begin
          sWhe := sWhe + 'Where (CodPart = :P' + IntToStr(i) +')'
        end
       else begin
        sWhe := sWhe + ' or (CodPart = :P' + IntToStr(i) + ')';
       end;
    end;
  end;
  Query1.SQL.Text := sWhe;

  ShowMessage(sWhe);

  for i := 0 to Lista2.Items.Count-1 do
   begin
    Query1.ParamByName('P'+IntToStr(i)).asString := Lista2.Items[i];
   end;

    Query1.Open;

    fmRelAt := tfmRelAt.Create(application);
    fmRelAt.QuickRep1.Preview;
    fmRelAt.Release 

Link para o comentário
Compartilhar em outros sites

  • 0

Bom, pelo texto seu dataset está correto.

O que pode ser é que você está com a Query1 vinculada ao datasource do DBGrid e este está 'mandando' na tabela.

Desvincule a Query1 do Datasource1 e clique no SpeedButton1.

Link para o comentário
Compartilhar em outros sites

  • 0

Nada....não deixei nada no DataSource do dbGrid e mesmo assim o relatório saiu na mesma.... wink.gif , eu estou achando que o QuickReport está com alguma propriedade que não deixa isso acontecer...pois quando a gente usar somente o QuickRep1.Preview, aparecem todos, se o código funciona redondinho no dbGrid, só não funcionaria no Relatório por este motivo.....

Ps..qualquer besteira que eu falei aqui, desconsidere... biggrin.gif

Link para o comentário
Compartilhar em outros sites

  • 0

CONSEGUIMOS biggrin.gif

É corposemalma...você está certo...eu não me conformei com o fato de ter tudo rolando no dbGrid e no Relatório dar errado....

O problema foi o seguinte :

O objeto que recebia os códigos era um QRExpression, ele que não deixava aparecer os selecionados....

Eu mudei de componente, coloquei um QRDBText para testar, apontei o Form que gerar o Relatório e funcionou que foi uma beleza.....

Foram 90 posts, dei muito trabalho para você o principalmente o s3c...obrigado ao Arlon também....

Olha o resultado

O sistema está pronto, só faltava isso...gerar os selecionados......agora eu vou fazer os ajustes galera......muito obrigado mesmo...

Senão fosse aqui eu estaria perdido.....

PS.Visita o meu blog e dá uma olhada no agradecimento que fiz a vocês :

Meu blog

biggrin.gifbiggrin.gifbiggrin.gif

Link para o comentário
Compartilhar em outros sites

Visitante
Este tópico está impedido de receber novos posts.



  • Estatísticas dos Fóruns

    • Tópicos
      152,1k
    • Posts
      651,8k
×
×
  • Criar Novo...