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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Set Decimal at run time

Status
Not open for further replies.

ashishjain

Programmer
Feb 20, 2002
32
IN
I am developing a project in VB/Acceess. I am generating a dynamic report using crystal report. The decimals of a numeric field is set at the design time, becuase report is dynamic any column may be swap means sometime a columns has decimals 2 and sometime 3. Is there any way to set or modify decimals at run time for a numeric field??

Thanx in advance.

Ashish


 
I do not know how to express this in VB, however I wrote a report like this once where the user was prompted via a parameter for how many decimals. (In your case I would imagine some code would take the place of the parameter).

If you right click the field object you want to conditionally change formats on in CR, select format field, go to the number tab, select customize and then click the
X-2 button to the right of decimals. Here you would enter your formula for conditional formatting:

If <<condition1>> then 2 else
if <<condition2>> then 3 else
if <<condition3>> then 4

The above formula will give you 2,3 and 4 decimals, resepctively.

Again, I do not know how to express this in VB, but I hope this helps. Software Support for Macola, Crystal Reports and Goldmine
dgillz@juno.com
 
Thanx dgillz,
Your tips really help me a lot and we can set decimal conditionally. If u don't mind i wanna ask another which is related with this.
I am passing all the title (@Title1,@Title2....) of the columns from VB and what i want to do, i have to check if passed value is Labour then it should show two decmial and it passed value is Net weight then decimal should be 3.

Thanx.

Ashish
 
If @title=&quot;Labour&quot; then 2 else 3 should work. As I read your post I believe you would have to do this for every column in your report that is numeric.

Again I do not know how to express this in VB.
Software Support for Macola, Crystal Reports and Goldmine
dgillz@juno.com
 
Thanx dgillz,
What u have written, i tried Yesterday...but its not working. Is any other way to check values of formula.

Regards,

Ashish
 
Make sure the field values are numeric.

If IsNumeric({Fieldname}) and @title=&quot;Labour&quot; then 2
else if IsNumberic({fieldname}) then 3
else DefaultAttribute

Again, the ONLY place to put this formula is rt click, format field, number tab, customize, X-2 button for conditional formatting. This is not a &quot;formula field&quot; it is a formula for object properties.

Again all of the above is in Crystal Reports. I am not a VB guy so I do not know how to express this in VB.

Let me know if there is anything else. You could email me your .rpt file if you like. Software Support for Macola, Crystal Reports and Goldmine
dgillz@juno.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top