CRO_Tomislav 0 Posted February 1, 2023 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
programmerdelphi2k 237 Posted February 1, 2023 (edited) 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. Edited February 1, 2023 by programmerdelphi2k Share this post Link to post
Fr0sT.Brutal 900 Posted February 2, 2023 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
CRO_Tomislav 0 Posted February 2, 2023 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