Data apears on Form, but not in Table

P

Pizza

My Access form asks for a date of birth as one entry, and is set to
automatically show age (years) in a second box. However, in Table View, this
column remains empty. How do I get this number to enter in the Table?
 
D

Douglas J. Steele

You don't, but then you don't really want it there anyhow, since the age
constantly changes.

Obviously you already know how to calculate age based on DOB. Put that
calculation in a query, and use the query rather than the table.
 
P

Pizza

Thanks for your reply, Douglas.
I'm not sure how to make my dilemma clear, as I'm not familiar with Access
beyond the very basics, and really not sure on all the correct lingo! So
bear with me - and I hope someone out there can help!!

I have a Text Box labelled age with the following entered as the "control
source"

=DateDiff("yyyy",[Birth Date],Now())+Int(Format(Now(),"mmdd")<Format([Birth
Date],"mmdd"))

Whenever I enter a DOB in the "Birth Date" text box, the years pop up in my
"Age" box. This number changes each year. But only appears on the form, not
in my table. I want to be able to query and find all entries in db between
ages 55-65. How do I do this?
 
D

Douglas J. Steele

As I already said, put the calculation into a query.

Create a new query and select the table in question. In an empty column in
the Field row of the grid, type the following:

Age: DateDiff("yyyy",[Birth
Date],Now())+Int(Format(Now(),"mmdd")<Format([Birth Date],"mmdd"))

Save the query.

Go to your form, and change its rowsource to that query you just created.

Go to the Age text box, and change its control source to Age.

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


Pizza said:
Thanks for your reply, Douglas.
I'm not sure how to make my dilemma clear, as I'm not familiar with Access
beyond the very basics, and really not sure on all the correct lingo! So
bear with me - and I hope someone out there can help!!

I have a Text Box labelled age with the following entered as the "control
source"

=DateDiff("yyyy",[Birth
Date],Now())+Int(Format(Now(),"mmdd")<Format([Birth
Date],"mmdd"))

Whenever I enter a DOB in the "Birth Date" text box, the years pop up in
my
"Age" box. This number changes each year. But only appears on the form,
not
in my table. I want to be able to query and find all entries in db between
ages 55-65. How do I do this?

Douglas J. Steele said:
You don't, but then you don't really want it there anyhow, since the age
constantly changes.

Obviously you already know how to calculate age based on DOB. Put that
calculation in a query, and use the query rather than the table.
 
L

Larry Linson

Pizza said:
I have a Text Box labelled age with the following
entered as the "control source"

=DateDiff("yyyy",[Birth Date],Now())+
Int(Format(Now(),"mmdd")<Format([Birth
Date],"mmdd"))

Whenever I enter a DOB in the "Birth Date" text box, the years pop up in my
"Age" box. This number changes each year. But only appears on the form, not
in my table. I want to be able to query and find all entries in db between
ages 55-65. How do I do this?

Given that to bind a Control to a Text Box, you specify the Field Name in
the Control Source; _and_ that to Calculate a Control, you pur the
Calculation in the Control Source, in just what Field would you expect that
Calculated Control to be saved?

Let me repeat what Doug already said in both his posts: You should not
store that calculated Field in the Table.

You should store Date of Birth and calculate the Age in the Query you use to
retrieve the data... a Calculated Field (into which you also cannot store
any data). Put the criteria in the Criteria lines of the Query Builder
under the Calculated Field to make our selection.

Larry Linson
Microsoft Office Access MVP
 

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