Fill a memo through a dataset by code

Hello,

I am trying to fill a memoView by code using GetDataset with MasterData3 not connected but without result, here's my code:
var
  ds: TfrxDataSet;

procedure MasterData3OnBeforePrint(Sender: TfrxComponent);
begin
   if not ds.Eof then
  begin              
  memo1.text :=ds.Value('Nom');
  end;
 ds.Next;               
end;

begin
 ds := Report.GetDataset('Ascendant');
  ds.First;                    
end.

I need to do that in the second page where the whole page has an image and the memo on it.
I have two record and only one (the first) is printed
Can you help me please ?

Comments

  • gordkgordk St.Catherines On. Canada.
    edited 4:35PM
    it seems like your first call to ds does not have the name of the dataset
    ie
    ds := Report.GetDataset('frxDBDataSet1');
  • edited 4:35PM
    I have made the call with the dataset wich appear at the right panel in fr editor. I have change it to frxDBDataSet1 as your advise so it doesn't work too.
    Anyway, I left this method and directly assigned memo to dataset I don't know why it doesn't worked for me before and know it works. Sorry for disturbing and thank you very much gordk
  • gordkgordk St.Catherines On. Canada.
    edited 4:35PM
    Sorry i missed the fact you had the dataset name in the begin end. block
    it must be a datasetname not a table name
    didn't mean to mislead you, not in office til tomorrow
  • gpigpi
    edited February 2017
    Attach your current report template (fr3), prepared report (fp3) and a sample what you want to get or send these files to support@fast-report.com

    If your MasterData3 not assigned with dataset - set MasterData3.RowCount to 1 - you will get text from the last record of the dataset
    If you want to show all records - use
    var
      ds: TfrxDataSet;
    
    procedure MasterData3OnBeforePrint(Sender: TfrxComponent);
    begin
                  
    end;
    
    begin
      ds := Report.GetDataset('Ascendant');
      ds.First;  
      MasterData3.RowCount := 1; 
      if not ds.Eof then
        begin              
          memo1.text :=ds.Value('Nom');
          Engine.ShowBand(MasterData3);
        end;
      ds.Next;                 
    end.
    
  • edited February 2017
    Despite I changed the method without using the call of datasetname since it worked for me I will try your solution tomorrow thank you gpi
  • edited 4:35PM
    Hello,

    Your solution works thanks gpi

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.