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

Divide field by a number?

Status
Not open for further replies.

Tony414

MIS
Feb 3, 2003
197
US
Hello,
I'm kind of a newb with crystal. I have a field {workstat.drive_c} that displays as number. I want to take this value and divivde it by 1000000. How would I do this? I tried a few things but keep getting a boolean error msg. Thanks in advance for the help.

Tony
 
If the field is a string, Use ToNumber({field}) to convert it. You should be able to say
Code:
ToNumber({field}) / 1000000

If that doesn't work, please post the formula. Usually best to post code that is failing and also give your Crystal version number.

[yinyang] Madawc Williams (East Anglia, UK). Using Windows XP & Crystal 10 [yinyang]
 
I think it's just a formula as easy as

TableName.FieldName / 1000000

replace TableName with your table, and FieldName with your field, and place the formula wherever you need it.
 
Here is what's in there already from the current report. I want to add the field {WORKSTAT.DRIVE_C} and divide it by 1000000. I tried both recommendation but they didn't work.


{ITEM.TYPE} = "Computer" and
{ITEM.SOURCE} <> 10 and
{WORKSTATION_COMPONENTS.ISCURRENT} = 1 and
{WORKSTATION_COMPONENTS.STATUSCODE} <> 4.00 and
{TYPE_CODE.TypeCodeType} = "HW"

Thanks,
Tony
 
Is this in an If block? If you're getting a Boolean error, it sounds like it is. Also, which of the fields has the #? It's not clear to me where and when you are dividing.
 
What you've shown is the Record Selection formula.
What, exactly, are you trying to accomplish by dividing by 1 000 000?

Bob Suruncle
 
I want to take the value of {WORKSTAT.DRIVE_C} and divide it by 1000000
 
I am trying to take the hard drive value. Which is in gigabytes and come up with a number like 80.0GB instead of 80000000000. I hope this makes sense....
 
I think you should show all of your code that is involved, partcularly that which is doing the division. There is no reference to WORKSTAT.DRIVEC in your sample so it's impossible to understand what is causing the problem.. I believe you have an issue with the underlying code, most likely caused by incorrect syntax, types, or scope. The division is as simple as the previous tips, once you are sure about what you are dividing.
 
I wrote the code in a msg above. The part with the division isn't in there because I don't know how to add it. Here it is again...

{ITEM.TYPE} = "Computer" and
{ITEM.SOURCE} <> 10 and
{WORKSTATION_COMPONENTS.ISCURRENT} = 1 and
{WORKSTATION_COMPONENTS.STATUSCODE} <> 4.00 and
{TYPE_CODE.TypeCodeType} = "HW"
 
If all you want to do is display this on the report, then there's no need to modify the Record Selection formula.
From the Field Explorer create a new Formula and name it Gigabytes

This assumes that your field is a Number type
Code:
{workstat.drive_c}/1000000000
Place this field on the report where you'd like it displayed. (probably the Details section)


Bob Suruncle
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top