Script not working

theodoretheodore Greece
edited 7:51PM in FastReport 2.xx VCL
I experience a problem when running a script on an OnBeforePrint event.
I have a Memo Object and i make it invisible just before band print but sometimes i have to make it visible.
Looks like it works ok when i print the report just one time (hides and shows correctly).
If i print the report multiple times (by calling every time the report again) the memo does not reset to invisible and is always visible. I tried to catch any logic or syntax error, but everything looks ok and some debug messageboxes i defined report the values and the script logic ok. The solution i gave was to send the object back and fill the above memos but i can not do it everytime.
Any suggestions?


Fastereport Rocks!!!

Comments

  • gordkgordk St.Catherines On. Canada.
    edited 7:51PM
    Theodore
    when you have a problem it would be good to show the code snippet/s in question, we cant't read your mind.
    Are you in the obp event of a band in a report or an obp event of the report component?

    regards ;)
  • theodoretheodore Greece
    edited 7:51PM
    Sorry, here is the code
    begin
    ExamName.Visible:=false;
    BackGround.Visible:=false;
    ExamNameFollow.Visible:=false;
    NameTitler.Visible:=false;
    LabelExamName.Visible:=false;
    ResultAsTitle.Visible:=false;
    RestResult.Visible:=false;
    Result.Visible:=true;
    Seperator.Visible:=false;
    FullLineResult.Visible:=false;
    if [QueryFindVisitPageExamFields."reporttype"] = 1 then ExamName.Visible:=true;
    if [QueryFindVisitPageExamFields."reporttype"] = 2 then
    begin
    ExamName.Visible:=true;
    ExamNameFollow.Visible:=true;
    RestResult.Visible:=true;
    Result.Visible:=false;
    end;
    if [QueryFindVisitPageExamFields."reporttype"] = 4 then LabelExamName.Visible:=true;
    if [QueryFindVisitPageExamFields."reporttype"] = 5 then
    begin
    if [QueryFindVisitPageExamFields."resulttype"] <> 8 then
    begin
    ResultAsTitle.Visible:=true;
    Result.Visible:=false;
    BackGround.Visible:=true;
    end;
    if [QueryFindVisitPageExamFields."resulttype"] = 8 then
    begin
    NameTitler.Visible:=true;
    ExamName.Visible:=false;
    ExamNameFollow.Visible:=false;
    BackGround.Visible:=true;
    end;
    end;
    if [QueryFindVisitPageExamFields."reporttype"] = 6 then
    begin
    FullLineResult.Visible:=true;
    Result.Visible:=false;
    end;
    if [QueryFindVisitPageExamFields."reporttype"] = 7 then Seperator.Visible:=true;
    if [QueryFindVisitPageExamFields."printtext"]= true then
    Begin
    RichNormalValue.Visible := true;
    PlainNormalValue.Visible := false;
    end;
    if [QueryFindVisitPageExamFields."printtext"]= false then
    Begin
    RichNormalValue.Visible := false;
    PlainNormalValue.Visible := true;
    end;
    if [QueryFindVisitPageExamFields."ViewLimitCheckResult"] = 0 then
    begin
    Result.Font.Style:=0;
    Result.Font.Color:=clBlack;
    end;

    if [QueryFindVisitPageExamFields."ViewLimitCheckResult"] = -1 then
    Begin
    Result.Font.Style:=2;
    Result.Font.Color:=clBlue;
    end;
    if [QueryFindVisitPageExamFields."ViewLimitCheckResult"] = 1 then
    Begin
    Result.Font.Style:=2;
    Result.Font.Color:=clRed;
    end;
    if Trim([QueryFindVisitPageExamFields."PrintName"])='' then
    begin
    ExamName.Visible:=false;
    ExamNameFollow.Visible:=false;
    end;


    end

    LabelExamName is the problem...
    The obp event exists in ;) detail data band
    But since yesterday i had another printing problem: When in a report which is almost full page with many fields on it, again in detail data, i placed 3 memos.
    By running the query, i can see the three values on screen, but not in the place i
    first had, them. They are printed after the band!!!. After that i cutted (ctrl-x) the memos and pasted (ctrl-v) them back. Everything now works!!!
    Bye
  • gordkgordk St.Catherines On. Canada.
    edited 7:51PM
    Hi What had happend was that your memos had become positioned out side of the band. thats why your cut paste worked. It some times happens when selecting a memo with the mouse that small movement while selecting causes the memo to jump up and get outside of the bands top and therefore belongs to page rather than the band, or a bad battery on a wireless scroll mouse.
    regards ;)
  • theodoretheodore Greece
    edited 7:51PM
    Hello again
    I discovered the problem (maybe a bug but obviously something not covered elsewhere) and reported to support.
    The problem is that:
    When you use a report object to print diffirent frf's, if at least one frf has an error on onbeforeprint, then the onbeforeprint event an all the other (with correct obp) reports looks like running but has no effect (does not actually work e.g. does not change visible properties).
    You must close and restart the application to make again the obp event run...


  • gordkgordk St.Catherines On. Canada.
    edited 7:51PM
    Look at code where you load and run report.
    typically
    frreport1.clear; // obvious
    frreport1.loadfromfile('path&filename.frf');
    if not frreport1.prepare report then
    exit
    else
    frreport1.showpreparedreport;

    regards ;)

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.