Precisions for label report

jezabeljezabel Angers, France
edited 6:35PM in FastReport 4.0
Hello,

I've red the topic on labels in binaries newsgroup but I can't run delphi to understand what it contains.
I run FR designer from the program.
I have to create a report for article labels with a name, a code and a price, with 3 columns and 21 labels/column (63 labels on the sheet, 21 x 29.7 cm).
The setting is ok.

But :
1) I can't see where to set the vertical gap between labels (the gap between 2 bands in View > Options only affects the design page).
I only have a masterdata band in my report.

2) I have to set a number of missing labels (labels which already have been printed on the sheet and removed) to restart on first remain label.

3) I have to set a number of copy for the band (for example : we want 3 labels of each article).

Could you help without transfering me a delphi source file ?

Thanks a lot

Jez.

Comments

  • gordkgordk St.Catherines On. Canada.
    edited 6:35PM
    the gap between labels across the page set the bands column width and column gap
    the vertical gap is set by making the band height equal to label height + gap, leave bottom page margin at 0.
    this will give horizontal out put 1, 2, 3
    for vertical
    1,5
    2,6
    3,7
    4,8
    use page columns

    add a memo object in the band the size of the label turn its frame lines on make it non printable
    it is just a guide to show the bounds of the label while designing
    you will need some variables to track the num of labels to print, the start position( the num of labels to skip), numberof lables printed, do not set the band's dataset property you will control it's position from your code.
    you set the band's rowcount to the record count of the dataset * the numcopies required,
    if you look way back in the binaries news group you will find a selfcontained label demo that i posted. just open the .fr3 file in your designer.
  • jezabeljezabel Angers, France
    edited 6:35PM
    Thank you for your answer.

    I set the row gap succesfully.
    The skip feature is working but not the copy number.
    The reason is I can't use the Datarow property because my masterdata band is connected to the dataset. This dataset comes from dephi and is the result of a stored procedure.

    Is there a solution ?

    Thanks again

    Jez.
  • gordkgordk St.Catherines On. Canada.
    edited 6:35PM
    at the top of the code page
    declare a variable of type tfrxdataset
    var

    ds: TfrxDataSet;

    use this code either in the empty "begin end." block of code or in the onstart report event.
    ds := Report.GetDataset('frxDBDataSet1'); // use either the name or username of the dataset.
    you can then get the record count of the dataset and move it using next prior first
    ie masterdata1 .rowcount := ds.recordcount * numcopy variable.
  • jezabeljezabel Angers, France
    edited 6:35PM
    Thank you again.
    But I still have problem :
    I changed the code because the "ds.next" was already done automaticaly and my copy number depend of each label.
    The result is ok until one asks more skip labels than the dataset recordcount. The engine stops at the recordcount number of skip labels.
    For example, if I ask 20 skip labels and the dataset counts 7 records, it displays only 7 skip labels.
    It would be easier if I could send you my FR file.
    Here is my code yet :
    var
      nbcopy, nbprinted, nbtoskip, skipcount: Integer;
      skip: Boolean;
      ds: TfrxDataSet;      
      
    procedure MasterData1OnBeforePrint(Sender: TfrxComponent);
    var
      i: Integer;
      obj: TObject;      
    begin                                                                                                    
             
      //?©tiquettes absentes                                             
      if skip then 
      begin
        //on cache les memos                 
        for i := 0 to Sender.Objects.Count - 1 do
        begin
          obj := Sender.Objects[i];
          if obj is TfrxMemoView then
            TfrxMemoView(obj).Visible := False;
        end;         
      end
        
      // affichage des ?©tiquettes      
      else                                                    
      begin
        
        if (<Line#>-1 = skipcount) then  //reprise des donn?©es apr??s un skip ou 1e ligne
        begin
          ds.First;
          nbprinted := 0;
          nbcopy := <dmArticle."STO_QTE_ETIQUETTE">;          
        end
        else
        begin                       
          if (nbprinted > 0) and (nbprinted <> nbcopy) then //revenir sur l'enregistrement, tant qu'on n'a pas imprim?© le nb de copies voulu  
            ds.Prior;
          if nbprinted = nbcopy then
            nbprinted := 0;          
          nbcopy := <dmArticle."STO_QTE_ETIQUETTE">;    //r?©actualisation de la variable ici                                                                                          
        end;
          
      end;  
            
    end;
    
    procedure frxReportOnStartReport(Sender: TfrxComponent);
    begin
      
      //nbimpcopy := <dmGestionImp."IMP_NBR_EXEMPLAIRE">;    
      nbtoskip := <dmImpression."ETIQUETTEABSENTE">;
      //showmessage('nb d''?©tiquettes absentes : ' + IntToStr(nbtoskip));                                    
      if nbtoskip > 0 then skip := True;
        
      ds := Report.GetDataset('dmArticle');                   
      //MasterData1.RowCount := ds.RecordCount + nbtoskip;; //(ds.RecordCount * nbimpcopy) + nbtoskip;
      //showmessage('nb de lignes : '+ inttostr(MasterData1.RowCount));          
      //showmessage('nb enregistrements : '+ inttostr(ds.RecordCount));   
        
    end;
    
    
    
    procedure MasterData1OnAfterPrint(Sender: TfrxComponent);
    var
      i: Integer;
      obj: TObject;
    begin
      
      if skip then
      begin
        Inc(skipcount);        
        if skipcount = nbtoskip then
        begin
          //Activer les memos et mettre skip ?  false                              
          for i := 0 to Sender.Objects.Count - 1 do
          begin
            obj := Sender.Objects[i];
            if obj is TfrxMemoView then
              TfrxMemoView(obj).Visible := True;
          end;
          skip := False;                          
        end;      
      end;  
        
    end;
    
    
    procedure Memo1OnAfterPrint(Sender: TfrxComponent);
    begin
        
      //enregistrer le nombre d'?©tiquettes imprim?©es                     
      if not skip then Inc(nbprinted);
    
    end;
    
    procedure memArtOnBeforePrint(Sender: TfrxComponent);
    var stMarque: String;                                
    begin
    
      //r?©actualisation des query
      IBXQFam.Close;      
      IBXQFam.Open;                  
      IBXQMar.Close;
      IBXQMar.Open;                              
       
      //designation de l'article
      if memArt.Visible then
      begin              
        if Length(<IBXQMar."MAR_NOM">) > 10 then
          stMarque := Copy(<IBXQMar."MAR_NOM">, 1, 10)
        else
          stMarque := <IBXQMar."MAR_NOM">;
        memArt.Memo.Text := Lowercase(Trim(Copy(<IBXQFam."FAM_NOM">, 1, 3) + ' ' + stMarque + ' ' + <dmArticle."ART_NOM"> + ' ' + <dmArticle."ATTRIB1"> + ' '  + <dmArticle."ATTRIB2"> + ' ' + <dmArticle."ATTRIB3"> + ' '  + <dmArticle."ATTRIB4"> + ' '  + <dmArticle."ATTRIB5"> + ' ' + <dmArticle."ATTRIB6"> + ' '  + <dmArticle."ATTRIB7"> + ' '  + <dmArticle."ATTRIB8"> + ' ' + <dmArticle."ATTRIB9"> ));
      end;            
      
    end;
    
     
    begin
      // initialisation des variables                                          
      nbcopy := 0;
      nbprinted := 0;
      nbtoskip := 0;      
      skip := False;                                              
      skipcount := 0;                              
    end.
    

    But I don't understand how this can work without using the OnManualBuild event.
    Thank for your advice.

    JEz.
  • gordkgordk St.Catherines On. Canada.
    edited 6:35PM
    your data set should not be connected to the band you are controling it's movement from code.
    the demo you downloaded runs fine, so you must be doing something wrong.
    zip and post your demo app in the binaries news group.
    in the meantime i will look at your code.
  • gordkgordk St.Catherines On. Canada.
    edited 6:35PM
    the first obvious thing i see is your ds variable should be initialized in the begin end. block at the bottom of the code page and set on first record not in the event of the databand.
  • jezabeljezabel Angers, France
    edited 6:35PM
    gordk wrote: »
    the first obvious thing i see is your ds variable should be initialized in the begin end. block at the bottom of the code page and set on first record not in the event of the databand.

    the ds variable is initialized in the report.onstartpage. You said in previous post that it could be done there as well.
    I don't understand the second part of your sentence :
    'and set on first record not in the event of the databand'
    You did make a Table1.First in the masterdataonbeforeprint in your demo. [img]style_emoticons/<#EMO_DIR#>/blink.gif" style="vertical-align:middle" emoid=":blink:" border="0" alt="blink.gif" /> My file is posted on binaries newsgroup. thanks Jez[/img]
  • gordkgordk St.Catherines On. Canada.
    edited 6:35PM
    from the fr3 you posted i still see the masterdatabands dataset property set to the dataset.
    the sample code and dialog from the demo should be ok for the skip portion.
    without data i can't test your data portion.
    the only reason i was able to move the ds as table1.next is the fact it was an internal table.
    Also since you appear to have a varying no of copies required for each record, you will have to determine a new rowcount prop value for the masterdataband before the report runs, you may need to make this value = to the num to skip + sum of the values in each record of the main dataset,
    this may require you to iterate through that table at the start of the report to determine that value, and of course when ever you move to the next record when running you will need to change the numcopy variable to suit.
    btw what is actual height width of a label in cm? , also when working with labels better to use pixels in design mode for better accuracy.
  • jezabeljezabel Angers, France
    edited 6:35PM
    I succeeded to run your demo only with connecting your masterdataband to an internal table that I took in my Database.
    Otherwise, I had a blank page : the MasterdataBand.OnBeforePrint event is not fired.
    That's why my databand is connected too. If it's not, the result is the same that your demo.

    Should I try with manual build now ?
    Label creation is not easy with FR >
  • gordkgordk St.Catherines On. Canada.
    edited 6:35PM
    look in the binaries newsgroup.
    at my latest reply.
  • jezabeljezabel Angers, France
    edited 6:35PM
    Ok it finally works but another problem occurs.

    I realized that it was maybe the onstartreport event so I put its code in the main proc and the masterdataonbeforeprint event fired.
    Labels print correctly now. Thanks.

    Everything was correct until I re opened the program :
    Now the recordcount number is wrong !
    1 record is counted.
    I created another report with masterdataband connected to the dataset in the same form (in a list) and then the recordcount number increases when I preview the connected report ! I must clic on each report several times to get the correct dataset records number in my first report.
    [img]style_emoticons/<#EMO_DIR#>/blink.gif" style="vertical-align:middle" emoid=":blink:" border="0" alt="blink.gif" /> Can you see where the problem is ? Thanks again Jez[/img]

Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.