Thanks for your responses. I will attempt to explain what I am doing so
bear
with me. Meanwhile, I will play with the advice I was given.
I want to create a database for a Parkinson's research project. Basically,
as the study subjects complete tasks(fields/controls), they each receive a
score based on the time it took to complete.
If they go over the time limit the recieve a score "0" [i.e unscramble
letter] (task1= F1 = 0).
If they complete above the 85th percentile, they score "100"[ i.e draw an
square]( task3= F3 = 100),
if they perform average they score "50" [i.e touch left knee with right
hand] (task2= F2=50), .
etc.etc.
If they don't want to do the task, I can't give them a score and leave the
value blank [hop on one foot = task8 = " " = null), .
So I need to tally the scores of each task and show the average for each
category (i.e mental (fields/controls) = F4 or physical limitation
(fields/controls)=F5, ) by dividing the total sum of tasks by the number
of
tasks completed. {maybe the calculation belongs in the query but I still
need
to account for null}
F1(0)+F2(50)+F3(100) = 150 -->150/3 = 50(F4) mental
F1(0)+F3(100)+F8(null) = 100-->100/2 = 50(F5) physical
Now for each patient visit, I would enter these scores for each task on a
new form and allow the database to calculate the scores entered and
average
the current visit categories (mental and physical)
Another small problem I see is that my primary key has to be a random
generated number to separate each visit(new forms) which I think I
accomplished. Each patient has at least three visits, so any identifier to
them can't be used as the primary key because of repetition.
Now with access, I hope to eliminate the hand writing/paper searching and
store the values for each visit to monitor the progression.
I then developed a query for each patient (i.e query Smith and query
Rivers)
to restrict the patient value
and then
Generate a report to show each visit. Smith 1/1/09, Smith 4/1/09, Smith
7/1/09.
Sorry to essay, but I will play with the advice already given. Any further
advice would be appreciated. Thanks again for the assistance
Jeff Boyce said:
First things first ... let's agree that even though you have F4 on your
form
(and by the way, on forms they are termed "controls", in tables they are
termed "fields" -- a "control" is like a window through which you see the
"field"'s value), you are NOT trying to store that "calculated value" in
your form's underlying table. It's rarely necessary and based on your
description, this is not one of the exceptions.
Next, "blank" may not = "blank". Even though you don't see anything in
the
control, this could be because the underlying field has no value (i.e.,
Null), or because the underlying field has a "zero-length string" (zls),
or
because the underlying field has spaces, or ... Those all look the same
to
the human eye. So look into using the Nz() function, which converts a
Null
to whatever you want (say, zero!). You could use something like:
Nz([F1],0)
Now, if you used Nz([F1],0] + Nz([F2],0) + Nz([F3],0), you'd get the sum
of
the (non-null) values.
But "0" can be meaningful! How many dollars do you have left in your
wallet? "0"! So how you do this will depend on what you are measuring.
You can put an expression in the Control Source property of your [F4] on
the
form in design view, and use the Nz() function, and other functions that
count the number of non-null values, but there's an underlying potential
issue.
If you have multiple fields in your table to store numbers that can be
added
together like this, you may be committing spreadsheet on Access. Using
multiple columns to capture numbers, then adding them together is
something
you'd do like this if limited to using a spreadsheet. But Access is a
relational database, not a spreadsheet.
Consider posting a bit more description about where these numbers came
from
and why you want to do this. Folks here may be able to offer ways for
you
to get more out of the tools Access offers.
Regards
Jeff Boyce
Microsoft Access MVP
I'm a novice at access and using Access 2000
There is probably a simple answer, but I can't make the operation work
so
specific details would probably help me considerably.
I have Four fields on a form: F1, F2, F3, F4
Say I populate the fields F1=0, F2=50 and F3=100
I would like F4 to add F1+F2+F3 as the fields are populated ----> 150
Okay now the trick, say F2 is left blank. so I want F4 to add F1 and
F3-->100
Trick #2: I would also like F4 to divide the total sum by the number of
fields populated. (i.e 150/3 or 100/2)
Thanks in advance