how to create labels with quick reports

Asked

Viewed 126 times

-1

I made a label printing works well, to print a label for each existing product or the Masterdata does correctly.

Except that for Label or that I wanted it to be the same product, if I repeated an agreement with the minimum amount used by the user, one question is how do I do this with Masterdata? Is it possible? I know that to print only one right product is to do a search and leave the storage in Dataset more in the same way that it will print 1 time and not a certain amount. EX: user entered the number 3 ai appears like this in another level

PRODUCT 1 PRODUCT 1 PRODUCT 1

I did so:

procedure TFm_Gerar.SELECIONARClick(Sender: TObject);
    var
    qtd : String;
    cont,ndias : integer;
    resultado,data : TDateTime;
    begin
    InputQuery('qtd','Informe quantas datas:',qtd);
    cont:= 1;
    ndias := dm.CDS_VERIFICA_PRODUTO.FieldByname('validade').AsInteger;
    data := Date;
    RESULTADO := data + ndias;
    if messagedlg('Deseja imprimir a 
    data?',MtConfirmation,mbYes,mbNo],0)=mrYes then
    begin

            while qtd >= (IntToStr(cont)) do
              begin
               cont:= cont +1;
              //  dm.data.LoadFromFile('data.fr3');
              //  dm.data.Variables['qtda'] := IntToStr(qtd); 
                dm.data.ShowReport;

              end;
          end;
end;

1 answer

0

Hello! There are many ways to do this. The most practical way is to create a temporary table linked to a Dataset. In this virtual information you carry out the printing process you want.

Something like that:

// Cria tabela temporaria
tabelaTemp.FileName:= 'nometabelatemporaria.xml';
with TabelaTemp do
begin
   FieldDefs.Clear;
   fieldDefs.Add( 'NOME', ftString, 60 );
   IndexDefs.Clear;
end;
TabelaTemp.CreateDataSet;
TabelaTemp.Active:= True;

qrConsulta.First;  // <---- Dataset ou componentes de dados que possui a informação a imprimir

while not qrConsulta.eof do
begin
   for i:= 0 to nQuantidade-1 do
   begin
       TabelaTemp.Insert;
       TabelaTemp.FieldByName( 'NOME' ).asString:= qrConsulta.FieldByName( 'NOME' ).asString;
       TabelaTemp.Post;
   end;
   next;
end;

TabelaTemp.first;
// A seguir roda o .fr3 vinculado ao dataset de sua TabelaTemp

frxReport1.ShowReport;

So you will be running the report once over a series of data. The time table does not even need to be saved, it will only allow replication to be performed. In a functional example I display a list of items and allow users to choose the desired amounts in each of them, press the print button and the system lists the respective labels. With few code changes you can also do this way. Success!

  • and the procedure I have made cited continues?

  • I don’t understand what you’re talking about? can you improve the question?

  • I do the code you gave me along with what I did?

  • You should try to understand based on the information I’ve given you. If you observe your method calls several times the printing routine, which for full-page reports (such as letters) would even serve, but not for labels. The approach I used is different, it is based on the same print with a range of data with the information so that it is easy to keep the report independent of the data. So you must choose one way or the other.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.