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!

Trying to divide two fields in a report!

Status
Not open for further replies.

scholarthewise23

Technical User
Jun 24, 2003
8
US
How do I go about doing this? Do I use a label? Is this is the expression I use? = 1-([FieldA]/[Field])
 
If you want to divide one field by another, assuming that they are both numeric, the syntax is:

=Field1/Field2

Of course, if field2 is 0, then it will crash with a division by zero error, so a better way is:

=Iif(Field2=0,"Div by 0 Error",Field1/Field2)

which just displays an error message rather than crashing.

John
 
Where do I put this syntax to make this happen in a report? Thanks for your reply!
 
Put a textbox on the report, and set its controlsource property to the expression.
You don't have to have the Field1 and field2 shown on the report, but they must be in the underlying data set.

John
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top