Query: "Double" Numeric Criteria Doesn't Work, But "Decmal" Does?

P

PeteCresswell

This is kind of involved to explain, so I made up a sample mini-
application and made it available for download from http://tinyurl.com/554xld

In a nutshell:
-------------------------------------------------------------------------------------
- I've got a "------- Program Changes -------" table whose PK is a
Double, named "VersionNumber"

- When I try to run a parameter-driven query against it - with
"theVerisonNumber" defined as Double, it doesn't seem to work.

- When I change the query's parameter to a Decimal, it works.

- Invoking the query from VBA code, however, it doesn't work either
way.

- Granted the table name is seriously goofy... but I've tried it with
the table renamed so "zstblProgramChanges" and nothing seems to
change.
------------------------------------------------------------------------------------

I've just frittered away almost two manhours on something that shb a
slam dunk.

Could some body take a look at the sample and tell me what I'm doing
that's dumb?
 
D

Douglas J. Steele

I didn't download the sample, but suspect that you were victim of floating
point inaccuracy.

Take a look at http://www.fmsinc.com/tpapers/math/index.html

One solution is to see whether the parameter's "close enough". Rather than

WHERE Field1 = [My Parameter]

use

WHERE Abs(Field1 - [My Parameter]) < 0.0001

(or whatever tolerance you want)
 
P

PeteCresswell

... but suspect that you were victim of floating point inaccuracy.

You nailed it!

Thanks.

That was the first time in my life I had ever used a Double as the
PK.

Sounds to me like it's generally a Bad Idea....
 

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