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

Convert Percentage into decimal in Microsoft Access query 1

Status
Not open for further replies.

THWatson

Technical User
Apr 25, 2000
2,601
CA
Using Access 2007

For whatever reason I am having a brain cramp here.

A electrician's database has a Materials Markup that could be anywhere from 0% to 20% (20% is the default but can be changed by the user).

In a query I want to convert that percentage to a decimal number.
e.g. change 20% to .2

In a form, the Val function does the trick, but not in a query.

What is the correct procedure?

Thanks.

Tom
 
What is the data type of the markup ?

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Hi PHV
In tblMaterials the field is "number", double, format percent

Tom
 
Did you try the CDec function in the query ?

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
The field is Markup, and assuming the value is 20%

CDec([Markup]) results in "function containing the wrong number of arguments"
CDec([Markup],2) results in "invalid use of Null"

Format([Markup],"Fixed") results in 0.20

[Markup]/100*100 results in 0.2
100*[Markup]/100 results in 0.2

I want to be sure that whatever I am using will be correct under all circumstances, as I need to calculate the total cost of Materials and then add whatever Markup the user has determined for that project.

Thanks.

Tom
 
And this ?
Nz([Markup],0)

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
PHV
Indeed, Nz([Markup],0) yields 0.2

Tom
 
And you'll avoid the "invalid use of Null" message ...

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top