data calculated in form field not showing up on table datasheet

G

glovesoff

Hi, I'm pretty new to Access, but I imagine this will be an easy fix.

I'm building a client census for a home health agency.

I have a Clients form that I fill out, and it puts the information in my
Clients table. One of the fields is Age at Admission, which uses DateDiff to
calculated a client's age from data in a Date of Birth field and Admission
Date field.

here is my code that is in the Control Source property of the Age At
Admission form field:
=DateDiff("yyyy",[DOB],[Admit Date])

Now, it's calculating the data correctly, as I can tell from scrolling
through the entries in Form View, but it isn't putting the calculation into
my Clients table (even though it puts all other information I enter into the
table).

So how can I get this calculated number to go from my Form into my Table?

Thanks!
 
F

fredg

Hi, I'm pretty new to Access, but I imagine this will be an easy fix.

I'm building a client census for a home health agency.

I have a Clients form that I fill out, and it puts the information in my
Clients table. One of the fields is Age at Admission, which uses DateDiff to
calculated a client's age from data in a Date of Birth field and Admission
Date field.

here is my code that is in the Control Source property of the Age At
Admission form field:
=DateDiff("yyyy",[DOB],[Admit Date])

Now, it's calculating the data correctly, as I can tell from scrolling
through the entries in Form View, but it isn't putting the calculation into
my Clients table (even though it puts all other information I enter into the
table).

So how can I get this calculated number to go from my Form into my Table?

Thanks!

First of all, the age you will get using your expression may not
necessarily be the actual age of the person at the time of admission.
What age will you get if you use the DOB of someone born 1/31/2008
being admitted today?
Using your expression, that person is 1 year old today. Try it and see
for yourself.

To correctly compute a persons age as of the date of admission, use:

Directly as the control source of an unbound control:

=DateDiff("yyyy",[DOB],[Admit Date])-IIf(Format([DOB],
"mmdd")>Format([Admit Date],"mmdd"),1,0)

Where [DOB] is the birthdate field.

Secondly, how would Access know into which field to store the data as
your control is not bound to any field?

Thirdly, there is no need, (and it should not be done) to save this
age value in any table. Any time you need to know the person's age at
the time of admittance, simply calculate it on a form or report, as
above, or in a query.
 
M

Maurice

As you stated this is a calculated field. These fields don't belong in a
table. It will not store your calculation in your table because you don't
have a bound field where to store it in. The field has a calculation as a
controlsource and that's exactly what it does it calculates the age. So in my
opinion don't change it because it's the way it should be.
 

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