Age Difference

G

Gavelle

I've created a field for age in days on my subform. I'm trying to calculate
the difference between date of birth (main form) and date of occurance
(subform).

Here is what i have so far:
=DateDiff("d",[Forms]![Patient Information]![DOB],[Date])

Have i created this correctly, and where should i put it in my properties?
I've tried putting it in "on enter" but nothing happens in the field when i
view my form.

Also, would it be better to make a more complex statement to calculate the
age over the new year? If so, where would i put this?

Thanks! I've tried searching in the discussion groups but i'm stalled now.
 
D

Dirtbike

Try the "On Exit" or the "After update" properties...the "On Enter" is as the
focus enters the control. You need to evaluate something after you know what
the control is.
 
L

Linq Adams via AccessMonster.com

Before you do anything else, you need to change the name of your "date of
occurance" field from Date to something else! Date is a reserved word in
Access and can cause you a world of problems! Assigning a value to Date such
as

Date = #12/31/2007#

will actually change the system date on your PC!

--
There's ALWAYS more than one way to skin a cat!

Answers/posts based on Access 2000/2003

Message posted via AccessMonster.com
 
A

Arvin Meyer [MVP]

Linq Adams via AccessMonster.com said:
Before you do anything else, you need to change the name of your "date of
occurance" field from Date to something else! Date is a reserved word in
Access and can cause you a world of problems! Assigning a value to Date
such
as

Date = #12/31/2007#

will actually change the system date on your PC!

What! I don't think so. Open an Access code window (Ctrl+G) and type in the
Immediate Window:

? Date = #1/3/07#
False

False is the return ands the system date remains unchanged. In order to do
what you want, one would need to open a command prompt and type:

Date = 12/31/2007
 
L

Linq Adams via AccessMonster.com

Do that same thing, but leave off the question mark and see what happens!

Date = #1/3/07#

--
There's ALWAYS more than one way to skin a cat!

Answers/posts based on Access 2000/2003

Message posted via AccessMonster.com
 
L

Linq Adams via AccessMonster.com

Or put the same code behind a command button!

Of course, this is in ACC2000 and ACC2003.

Your results may vary!

--
There's ALWAYS more than one way to skin a cat!

Answers/posts based on Access 2000/2003

Message posted via AccessMonster.com
 
A

Arvin Meyer [MVP]

I stand corrected. I wonder if it is possible on a system where Group Policy
forbids a user to access a cmd screen or change the date. I'd appreciate it
if anyone on a locked down system could answer.
 
D

Douglas J. Steele

I'm going by memory now (because I'm at home on vacation), but I'm pretty
sure we can't reset the date in that way on our system (where the user has
been prevented from resetting the time through group policies). I'll try and
pull out my corporate machine and test later today.

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)
 
L

Linq Adams via AccessMonster.com

It'd be interesting to know! Of course, even if this would preclude the
changing, there's gazillion small-medium sized companies where Group Policies
aren't in place. When calculations/queries involving the current date start
going haywire, who would think to actually check the system date? Like the
sun and the moon, it's supposed to just be there!

--
There's ALWAYS more than one way to skin a cat!

Answers/posts based on Access 2000/2003

Message posted via AccessMonster.com
 
D

Douglas J. Steele

Just tried my corporate machine, and it looks as though they've actually
given us the ability to reset the time so I won't be able to check for you.

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)
 
D

David W. Fenton

Before you do anything else, you need to change the name of your
"date of occurance" field from Date to something else! Date is a
reserved word in Access and can cause you a world of problems!
Assigning a value to Date such as

Date = #12/31/2007#

will actually change the system date on your PC!

This is because Date is not just a function, but also a STATEMENT.
There are several Access functions that are also statements, like
Mid(), for instance. Time() is another. Glancing through the A97
Statements Reference, no others jump out at me, but there may be
more.
 

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