Is Weight in pounds and Hgt (height I'm assuming) in inches? If so I'm
getting some strange numbers from your calculation of
([Weight]/([Hgt]*[Hgt])*10000). The number is expotentially small to almost
zero. Maybe that could be the cause.
Here's my vitals
For WEIGHT: 215 Lbs. (97.5 Kg); HEIGHT: 6 Ft., 1 In. (185.4 CM)
Body Mass Index (BMI) = 28.37 - Overweight.
(In my defense, I've ridden my bicycle over a thousand miles so far this
year including 145 miles this past weeked. I need to back off from the table
I guess.)
Anyway I digress. Let's try simplifying your query as you said that it
started going bad when you entered criteria. Try this first:
SELECT [Single Radiographs].Gycm2, PatientDetails.Weight
FROM [Single Radiographs] INNER JOIN PatientDetails ON [Single
Radiographs].UniqueNo = PatientDetails.UniqueNo
WHERE (((PatientDetails.Weight)>=82
and (PatientDetails.Weight)<=90)
and ((([Weight]/([Hgt]*[Hgt])*10000))>=20
and (([Weight]/([Hgt]*[Hgt])*10000))<=33));
Any problems? If not try this:
SELECT [Single Radiographs].Gycm2, PatientDetails.Weight
FROM [Single Radiographs] INNER JOIN PatientDetails ON [Single
Radiographs].UniqueNo = PatientDetails.UniqueNo
WHERE (PatientDetails.Weight)>=82
and (PatientDetails.Weight)<=90) ;
Then this:
SELECT [Single Radiographs].Gycm2, PatientDetails.Weight
FROM [Single Radiographs] INNER JOIN PatientDetails ON [Single
Radiographs].UniqueNo = PatientDetails.UniqueNo
WHERE ([Weight]/([Hgt]*[Hgt])*10000)>=20
and ([Weight]/([Hgt]*[Hgt])*10000)<=33 ;
Here's using Between statements:
SELECT [Single Radiographs].Gycm2,
PatientDetails.Weight,
([Weight]/([Hgt]*[Hgt])*10000) AS BMI
FROM [Single Radiographs] INNER JOIN PatientDetails ON [Single
Radiographs].UniqueNo = PatientDetails.UniqueNo
WHERE (PatientDetails.Weight) BETWEEN 82 and 90
AND ([Weight]/([Hgt]*[Hgt])*10000) BETWEEN 20 and 33;
--
Jerry Whittle
Light. Strong. Cheap. Pick two. Keith Bontrager - Bicycle Builder.
D Stretton said:
Sorry, the SQL previously posted was without criteria. Here it is with
criteria for weight and BMI included:
-- SELECT [Single Radiographs].Gycm2, PatientDetails.Weight,
([Weight]/([Hgt]*[Hgt])*10000) AS BMI
FROM [Single Radiographs] INNER JOIN PatientDetails ON [Single
Radiographs].UniqueNo = PatientDetails.UniqueNo
WHERE (((PatientDetails.Weight)>=82 And (PatientDetails.Weight)<=90) AND
((([Weight]/([Hgt]*[Hgt])*10000))>=20 And
(([Weight]/([Hgt]*[Hgt])*10000))<=33));
Don
:
Hi Wayne
Thanks for the reply. This is the SQL:
SELECT [Single Radiographs].Gycm2, PatientDetails.Weight,
([Weight]/([Hgt]*[Hgt])*10000) AS BMI
FROM [Single Radiographs] INNER JOIN PatientDetails ON [Single
Radiographs].UniqueNo = PatientDetails.UniqueNo;
I regularly run compact and repair. Am opening the query itself. You're
right - using ABS was unnecessary - have removed this but still get same
problem.
Should have said that I've run loads of queries over past 2/3 years using
BMI and criteria and never used to have a problem. This has only happened
fairly recently.
--
Don
:
Please post the SQL view of the query.
Have you done a Compact and Repair? This will redo the indexes on the tables
in case they are corrupted and messing up the query. Are you opening the
query itself or viewing its results in a form or report?
Just to try and simplify things to eliminate possible problems, I don't
understand the need for Abs(). Unless Weight can be negative, there is no
way to get a negative value from the equation (Hgt^2 will always be a
positive result and 10000 is positive).
--
Wayne Morgan
MS Access MVP
I am running a query using 2 tables. One field in the query works out BMI
using the formula Abs([Weight]/([Hgt]*[Hgt])*10000), both the weight and
height come from one table. If I don't put in any criteria for this it is
happy and returns BMI values. As soon as I introduce criteria for BMI
e.g.
=17.5 And <=30.5 then I get a division by zero message and the query will
not run. I have checked and here are no zero values in my data.
Yesterday I
created an identical query from scratch and it ran fine using BMI and
criteria. Today I have created a different query using BMI and criteria,
it
runs the query and I can see correct values in the fields but after ~2
seconds the message 'division by zero' appears and the fields change and
all
return the value #Name?. Does anyone have any ideas what the problem
is?
Thanks in advance.