Dlookup returning weird values?

Q

Question Boy

Hello,

I have a table with 2 columns, Local & Reginal which are Number type
(single, percent, 4 decimal places). I entered 0.05 and 0.07 respectively
and when I check the table values they are correct.

However, I have a form in which I use Dlookup to get these values. It
returns the values 0.0500000007450581 & 0.07500000298? Why?

I continued trying all sorts of changes and found that if I surrounded my
Dlookup in a Val() it then returned the correct value?

I have a solution, but do not understand the root cause of the original
problem. I would like to know what was causing it to ensure I avoid this in
future databases.

Thank you,

QB
 
R

Rick Brandt

Question said:
Hello,

I have a table with 2 columns, Local & Reginal which are Number type
(single, percent, 4 decimal places). I entered 0.05 and 0.07
respectively and when I check the table values they are correct.

However, I have a form in which I use Dlookup to get these values. It
returns the values 0.0500000007450581 & 0.07500000298? Why?

I continued trying all sorts of changes and found that if I
surrounded my Dlookup in a Val() it then returned the correct value?

I have a solution, but do not understand the root cause of the
original problem. I would like to know what was causing it to ensure
I avoid this in future databases.

Thank you,

QB

The types Single and Double are imprecise. They often store only
approximately the value entered into them. To avoid rounding issues such as
you are seeing you have to switch to Currency or Decimal data types. Note
that Access' implementation of the Decimal type is not perfect.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top