Number format

I have following functions to set sub total at Group Header. And it works fine except the format of both sub total. I would like to let it become something like "$123,789.00". I tried to set both format on memo9 and memo6. But they won't work at all.

function GroupHeader1OnBeforePrint(Sender){
if (Engine.FinalPass){
Memo9.Text = formatCurrency(Get(<ADOQuery1."duedate">));
}
}

function GroupFooter1OnBeforePrint(Sender){
Set(<ADOQuery1."duedate">,
<SUM(<ADOQuery1."totalamt">, MasterData1)> -
<SUM(<ADOQuery1."totalpaid">, MasterData1)>
);
}
function GroupHeader2OnBeforePrint(Sender){
if (Engine.FinalPass){
Memo6.Text = Get(<ADOQuery1."duedate">);
}
}

function GroupFooter2OnBeforePrint(Sender){
Set(<ADOQuery1."duedate">,
<SUM(<ADOQuery1."totalamt">, MasterData1)> -
<SUM(<ADOQuery1."totalpaid">, MasterData1)>
);
}

Comments

  • edited 1:20PM
    sorry there is an error on function it should be "Memo9.Text = Get(<ADOQuery1."duedate">);" Originally I tried to write a format function to format it. But Jscript on Fastreport has so much limitation. I can't use regular expression. So fail to do it in that way.

  • gpigpi
    edited 1:20PM
    Try this (Pascal script):
    Memo9.Text := Format('%2.2m',[Get(<Sales."Company">)]);
  • edited 1:20PM
    Thank you so much! It does work. I try to use Jscript with Format() but it won't work. Obviously "Format()" is part of Pascal. So I have to change all functions to Pascal procedures. I've struggled with this problem for weeks by asking FastReport support. Well, most answers didn't hit the point. Huh! Thank you again!
  • gpigpi
    edited 1:20PM
    See support ticket # 197164:
    wrote:
    You can't to use DisplayFormat for text, just for expressions.
    You must format memo's text in code:
    function Memo4OnBeforePrint(Sender)
    {
        if (Engine.FinalPass)
        Memo4.Text = "Sum: " + Format("%2.2m", [Get(<Sales."Company">)]);  
    }
    
    wrote:
    I've struggled with this problem for weeks by asking FastReport support. Well, most answers didn't hit the point. Huh!
    Please, next time send small demo project with problem based on FRDemo database
    This will accelerate the solution of the problem


  • edited 1:20PM
    wrote:
    Please, next time send small demo project with problem based on FRDemo database
    This will accelerate the solution of the problem
    Yes, I will thank you so much!

    Does Format( ) works in jscript?
  • gpigpi
    edited 1:20PM
    wrote:
    Does Format( ) works in jscript?
    Yes. See a test report template for FRDemo Database in attach
  • edited 1:20PM
    Thank you so much. I now changed back to jscript and it works fine. Because I know javascript much better than the other else. By the way, How do you know there is function of Format provided by fastreport. Can you show me which manual I can refer to it? Thank you again!
  • gpigpi
    edited 1:20PM
    See Functions tab in Data Tree
  • edited 1:20PM
    See Functions tab in Data Tree[/quote]Thank you so much! I found, in function arguments, when refer to a database field should be enclosed with "<>" rather than "[]".

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.