Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how can I change the format for a field with a variable? 1

Status
Not open for further replies.

isdn123

IS-IT--Management
Feb 3, 2005
3
RO
I'm new on this forum and in the first time I want to give thanks to IBass who helped me, yesterday, only when I read one of his answers.
But , I have another problem and maybe you can help me.

In one of my subreports I need to appear a numeric field with 2 decimals or without decimals; this was made with a condition;

I created a variable in a subreport:

WhilePrintingRecords;
NumberVar valTVA;
valTVA:= ToNumber ({sbtable.TVA1})*ToNumber ({sbtable.TVA2}/100);
if {@tipvaluta}="AR" then valTVA:=Round (valTVA,2 );
valTVA;

where sbtable = subreport table

and my field it's set up from Format field -> Customize like this:

Decimals 1.00
Round 0.01

where @tipvaluta it's a shared variable created in my report, because only from there I can take the value:

WhilePrintingRecords;
shared stringvar tipvaluta:=" ";
tipvaluta:={rtable.TIP};
tipvaluta;

where stable= report table

and in my subreport:

WhilePrintingRecords;
shared stringvar tipvaluta;
tipvaluta;

And everything was ok with my shared variable , but in my report it doesn't appear without decimals.

What can I do?

 
I think you could simplify this. In the main report, create the shared variable:

WhilePrintingRecords;
shared stringvar tipvaluta :={rtable.TIP};

Be sure to place this somewhere on the main report.

Then in the subreport create your formula:

WhilePrintingRecords;
NumberVar valTVA;
valTVA:= ToNumber ({sbtable.TVA1})*ToNumber ({sbtable.TVA2}/100);

The subreport must be placed in a section below the one in which your main report shared variable is placed. Then in the subreport, right click on your formula (which is placed on the subreport canvas)->format field->number->customize->decimals->x+2 and enter:

WhilePrintingRecords;
shared stringvar tipvaluta;

if tipvaluta = "AR" then 2 else 0

This will display either two decimals or none. The rounding is up to you.

-LB
 
Thank you very much Ibass for your help; it was more then usefull especially I gained time and experience.
Thanks, again!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top