Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Queries / June 2006

Tip: Looking for answers? Try searching our database.

Format Numbers in IIF statement

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
alecgreen - 30 Jun 2006 19:03 GMT
Hi, I am using the following IIF statement to calculate the percentage
difference between a Selling Price and a Order Selling Price, bearing
in mind you cannot deivide by zero!

OrdvsSell: IIf([SellingPrice]=0,"NO
CALC",(([OrderSellingPrice]-[SellingPrice])/[SellingPrice]*100))

However I cannot format the result to say 2 decimal places, instead of
the actual calculated result - Can this be done within the IIF
statement?

Thanks

Alec
Marshall Barton - 30 Jun 2006 19:29 GMT
>Hi, I am using the following IIF statement to calculate the percentage
>difference between a Selling Price and a Order Selling Price, bearing
[quoted text clipped - 6 lines]
>the actual calculated result - Can this be done within the IIF
>statement?

The problem probably is that the result is being converted
to a string because of the possible "NO CALC" result.

Try this:

OrdvsSell: IIf([SellingPrice]=0,"NO
CALC",Format(([OrderSellingPrice]-[SellingPrice])/[SellingPrice]),
"0.00%" )

Signature

Marsh
MVP [MS Access]

Jeff L - 30 Jun 2006 19:40 GMT
Yes.
OrdvsSell: IIf([SellingPrice]=0,"NO
CALC",Round((([OrderSellingPrice]-[SellingPrice])/[SellingPrice]*100),2))
This will round your result to 2 decimal places.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.