Jump to content
CRO_Tomislav

Transfer variable or fixed tekst to FastReport

Recommended Posts

Dear all.

 

I am new to FastReport and I have some basic issue with him…

 

On a Delphi Form with others components I have a frxReport1.

In that report, in a section of variables I create a new group of variables named MyVar.

In that group I create 4 variables named: OSKAR_Month, OSKAR_Year, OSKAR_Days, OSKAR_Hours with default expressions.

 

On a vcl form I have a button which has for test next code:

 

with frxRbeport1 do

begin

 Variables.Variables['OSKAR_Year']:= QuotedStr(IntToStr(YearOf(MonthCalendar1.Date))); 

 Variables.Variables['OSKAR_Month']:= QuotedStr(FormatDateTime('mmmm',MonthCalendar1.Date));

 Variables.Variables['OSKAR_Days']:= LabelData3.Caption;

 Variables.Variables['OSKAR_Hours']:= LabelData4.Caption;

end;

frxReport1.ShowReport(True);

 

I am trying to transfer some simple variables or fixed tekst to report but this code doesn't work. Only OSKAR_Year is transferred.

How to transfer this data to report?

 

THX in advance

Tomislav

Share this post


Link to post

try this:

implementation

{$R *.dfm}

uses
  System.DateUtils;

procedure TForm1.Button1Click(Sender: TObject);
begin
  frxReport1.Variables['MyVar1'] := QuotedStr(DayOf(Now).ToString);
  frxReport1.Variables['MyVar2'] := QuotedStr(MonthOf(Now).ToString);
  frxReport1.Variables['MyVar3'] := QuotedStr(YearOf(Now).ToString);
  frxReport1.Variables['MyVar4'] := QuotedStr(Now.ToString);
  frxReport1.PrepareReport;
  frxReport1.ShowReport;
end;

end.

image.thumb.png.952e0effcc69bb6ceb7b69c8026a34ea.png

Edited by programmerdelphi2k

Share this post


Link to post

Could be useful

// Prepare string value for FastReport Variable assignment
// If s is empty, return Null (FR dislikes empty ('') vars)
// If s is one-line string (without CRLF) it must be quoted
// If s is multiline, no change is required
function FRStrVar(const s: string): Variant;
begin
  if s = '' then
    Result := Null
  else if Pos(sLineBreak, s) = 0 then
    Result := QuotedStr(s)
  else
    Result := s;
end;

 

Share this post


Link to post

Hello.

 

It still didn't trasfer all varaibles fo frxReport1...

When I rename variable OSKAR_Month in report... - it works!

 

Thanks for help

Tomislav

 

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×