Locate in report Script

Hello all,

Is it possible to do a locate in report's script ?
I have a dataset : DS.
I initialize it with that line of code :
DS:=Report.GetDataset('Data');

And tried to do my locate with that code :
if DS.DataSet.Locate('CodeRubrique;mois', VarArrayOf([rub,i])) then
            begin
              ShowMessage('Msg : ' + VartoStr(DS.Value('valeur')));
              ShowMessage('Msg : Valeur n''est pas vide :' + VartoStr(DS.Value('valeur')));
              memo8a.Lines[0] := formatFloat('### ### ##0', DS.Value('valeur'));
              memo8b.Lines[0] := formatFloat('### ### ##0', DS.Value('ssvaleur'));

              DS.NEXT; // Enregistrement suivant
            end

I've tried to make my if statement like in the previous code but getting an error message :
" 'Dataset' is not declared. " (Probably not the exact message because I use it in French and translate it just for you [img]style_emoticons/<#EMO_DIR#>/wink.gif" style="vertical-align:middle" emoid=";)" border="0" alt="wink.gif" /> ) Then I've tried the same without .DataSet :[/img]
if DS.Locate('CodeRubrique;mois', VarArrayOf([rub,i])) then

I get the same error message for 'Locate'.



FYI, here is the entire code of the report :
// Parcours de la liste des champs d'une query Delphi
// Ne pas affecter de Dataset ?  la MasterDataBand
procedure Page1OnManualBuild(Sender: TfrxComponent);                                               
var DS: TfrxDataSet;
    i, lig, col : integer;
    rub : string;
begin
  //Chargement du DataSet en provenance de Delphi
  DS.First;      
end;

procedure MasterData1OnBeforePrint(Sender: TfrxComponent);
begin

end;

procedure DetailData1OnBeforePrint(Sender: TfrxComponent);
var DS: TfrxDataSet;
    i, lig, col : integer;
    rub : string;                                  
begin
                                                          
  //Chargement du DataSet en provenance de Delphi                                                                                                                                                        
  DS:=Report.GetDataset('Data');  
  //MasterData1.RowCount := DS.RecordCount;        
  i := 0;    
                                   
  while not DS.Eof do
  begin
    rub := DS.Value('CodeRubrique');                              
    MemoCode.Lines[0] := DS.Value('CodeRubrique');
    MemoDesign.Lines[0] := DS.Value('LibelleRubrique');
    MemoUnit.Lines[0] := DS.Value('Unite');        

    for i := 1 to 12 do
    begin
      if rub = DS.Value('CodeRubrique') then
      begin
        case i of
          1:
          begin
            if DS.Value('mois') = i then
            begin                        
              memo1a.Lines[0] := formatFloat('### ### ##0', DS.Value('valeur'));
              memo1b.Lines[0] := formatFloat('### ### ##0', DS.Value('ssvaleur'));                 
              DS.NEXT; // Enregistrement suivant
            end;                                      
          end;                                   
          2:
          begin                      
            if DS.Value('mois') = i then
            begin
              memo2a.Lines[0] := formatFloat('### ### ##0', DS.Value('valeur'));
              memo2b.Lines[0] := formatFloat('### ### ##0', DS.Value('ssvaleur'));                 
              DS.NEXT; // Enregistrement suivant
            end;                               
          end;                                   
          3:
          begin                      
            if DS.Value('mois') = i then
            begin
              memo3a.Lines[0] := formatFloat('### ### ##0', DS.Value('valeur'));
              memo3b.Lines[0] := formatFloat('### ### ##0', DS.Value('ssvaleur'));                 
              DS.NEXT; // Enregistrement suivant
            end;                                
          end;                                   
          4:  
          begin                      
            if DS.Value('mois') = i then
            begin
              memo4a.Lines[0] := formatFloat('### ### ##0', DS.Value('valeur'));
              memo4b.Lines[0] := formatFloat('### ### ##0', DS.Value('ssvaleur'));                 
              DS.NEXT; // Enregistrement suivant
            end;                               
          end;                                   
          5:  
          begin                      
            if DS.Value('mois') = i then
            begin
              memo5a.Lines[0] := formatFloat('### ### ##0', DS.Value('valeur'));
              memo5b.Lines[0] := formatFloat('### ### ##0', DS.Value('ssvaleur'));                 
              DS.NEXT; // Enregistrement suivant
            end;                                
          end;                                   
          6:  
          begin                      
            if DS.Value('mois') = i then
            begin
              memo6a.Lines[0] := formatFloat('### ### ##0', DS.Value('valeur'));
              memo6b.Lines[0] := formatFloat('### ### ##0', DS.Value('ssvaleur'));                 
              DS.NEXT; // Enregistrement suivant
            end;                       
          end;                                   
          7:  
          begin                      
            if DS.Value('mois') = i then
            begin
              memo7a.Lines[0] := formatFloat('### ### ##0', DS.Value('valeur'));
              memo7b.Lines[0] := formatFloat('### ### ##0', DS.Value('ssvaleur'));                 
              DS.NEXT; // Enregistrement suivant
            end;                 
          end;                                   
          8:  
          begin                        
            if DS.DataSet.Locate('CodeRubrique;mois', VarArrayOf([rub,i])) then
            begin
              ShowMessage('Msg : ' + VartoStr(DS.Value('valeur')));
              ShowMessage('Msg : Valeur n''est pas vide :' + VartoStr(DS.Value('valeur')));
              memo8a.Lines[0] := formatFloat('### ### ##0', DS.Value('valeur'));
              memo8b.Lines[0] := formatFloat('### ### ##0', DS.Value('ssvaleur'));

              DS.NEXT; // Enregistrement suivant
            end
            else
            begin
              ShowMessage('Msg : Valeur EST VIDE !');  
            end;                        
                
          end;
          9:  
          begin
            if DS.Value('mois') = i then
            begin
              if DS.Value('valeur') <> '' then
              begin              
                memo9a.Lines[0] := formatFloat('### ### ##0', DS.Value('valeur'));
                memo9b.Lines[0] := formatFloat('### ### ##0', DS.Value('ssvaleur'));                  
                DS.NEXT; // Enregistrement suivant
              end;
            end;                                
//            else
//              memo9a.Lines[0] := '0';                                                                                                                              
          end;                                   
          10:  
          begin                      
            if DS.Value('mois') = i then
            begin
              memo10a.Lines[0] := formatFloat('### ### ##0', DS.Value('valeur'));
              memo10b.Lines[0] := formatFloat('### ### ##0', DS.Value('ssvaleur'));                 
              DS.NEXT; // Enregistrement suivant
            end;                 
          end;                                   
          11:    
          begin                      
            if DS.Value('mois') = i then
            begin
              memo11a.Lines[0] := formatFloat('### ### ##0', DS.Value('valeur'));
              memo11b.Lines[0] := formatFloat('### ### ##0', DS.Value('ssvaleur'));                 
              DS.NEXT; // Enregistrement suivant
            end;                               
          end;                                   
          12:  
          begin                      
            if DS.Value('mois') = i then
            begin
              memo12a.Lines[0] := formatFloat('### ### ##0', DS.Value('valeur'));
              memo12b.Lines[0] := formatFloat('### ### ##0', DS.Value('ssvaleur'));                 
              DS.NEXT; // Enregistrement suivant
            end;                       
          end;                                   
        end;                              
        //Memo3.Lines[0] := DS.Value('valeur');                                                                                                                                                                                                                                                                                                                       
      end
      else
        exit;                 

    end;        
    Engine.ShowBand(DetailData1);    //On force l'affichage du detailBand sinon, affichage de X ligne avec les donn?©es du dernier r?©sultat du DS

    DS.NEXT; // Enregistrement suivant
    //end;              
    //Memo3.Lines[0] := Memo3.Lines[0] + IntToStr(i);  
    //inc(i);
    // Acc??s aux donn?©es                                                      
    // Affectation des donn?©es au M?©mo3
    
//    MemoDesign.Lines[0] := DS.Value('LibelleRubrique');        
    //MemoCode.Text := DS.Value('CodeRubrique');
    //MemoDesign.Text := DS.Value('LibelleRubrique');              
         
//    DS.NEXT; // Enregistrement suivant                                                                                                                                           
  end;
end;

begin
      
end.

Comments

  • edited 6:46AM
    I've made a mistake on the locate's code part. I've tried to make the locate with these 2 lines of code (one after the other) :
    if DS.Locate('CodeRubrique;mois', VarArrayOf([rub,i], 0)) then
    ---------------------------------------------------------------------------------------------
    if DS.DataSet.Locate('CodeRubrique;mois', VarArrayOf([rub,i], 0)) then
    
  • For those interested :


    procedure chSDRMsupportOnBeforePrint(Sender: TfrxComponent);

    var sdrm:TfrxDBDataset;                                            

    begin

     sdrm:=TfrxDBDataset(Report.GetDataset('frxSDRM'));

     sdrm.Open;                       

     sdrm.Locate('uniqueobjectid',<frxMVEN."uniqueobjectid">,0);                                                                                                

    end;

    See : http://www.bytemaster.ru/?page_id=2026

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.