Creating a calculated field using dates in a form

B

Becajo

I am trying to use dates from 2 fields in a form (HireDate-DOB) to calculate
age. Then, using the age, I want to display a message if the age is less
than 18. I think I have written a conditional statement correctly, but am
unsure where to place it so that the message displays when the condition is
met.

I am totally new to Access 2007 and VB.
 
K

KARL DEWEY

You did not say what the content of your 'conditional statement' was and how
you plan on using it.
What has HireDate to do with it? Is it you want to see if their age is
less than 18 on the date of hiring? Then this will check if your dates are
stored in a date field and not in text.

IIF(DateDiff("yyyy", [HireDate], [DOB]) <= 18, "Place your statement
here", "")

Or --
IIF(DateDiff("yyyy", [HireDate], [DOB]) <= 18, "Place your statement
here", "Welcome")
 
D

De Jager

Becajo said:
I am trying to use dates from 2 fields in a form (HireDate-DOB) to
calculate
age. Then, using the age, I want to display a message if the age is less
than 18. I think I have written a conditional statement correctly, but am
unsure where to place it so that the message displays when the condition
is
met.

I am totally new to Access 2007 and VB.
 

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