DateDiff Question

F

Fred Worthington

Greetings:

I am calculating AGE from the DOB field by using the following expression:


=DateDiff("yyyy",[DOB],Date())+(Format([DOB],"mmdd")>Format(Date(),"mmdd"))

This works perfectly as long as both fields reside in the same form. How do
I revise my syntax to calculate the AGE from a DOB field in another Form?
Note: I am not an expert in the use of syntax.

Thanks . . . Fred
 
R

Rick B

I think you would simply replace [DOB] with the following...

Forms![MyFormName]![MyFieldName]
 
F

Fred Worthington

Thanks, Rick:

Wow, that was fast! I tried the substitution you suggested but Access will
not accept the expression exactly as I entered it. This is what the
expression looks like now:

=DateDiff("yyyy",[Forms![ClientData]!DOB,Date())+(Format([DOB],"mmdd")>Forma
t(Date(),"mmdd"))

Unfortunately this results in the dread #Name? symbol in the Age field.
Perhaps you can help me revise this expression to achieve the desired result
(where ClientData is the Form that contains the DOB field).

Thanks . . . Fred


Rick B said:
I think you would simply replace [DOB] with the following...

Forms![MyFormName]![MyFieldName]





Fred Worthington said:
Greetings:

I am calculating AGE from the DOB field by using the following expression:
=DateDiff("yyyy",[DOB],Date())+(Format([DOB],"mmdd")>Format(Date(),"mmdd"))
This works perfectly as long as both fields reside in the same form.
How
do
I revise my syntax to calculate the AGE from a DOB field in another Form?
Note: I am not an expert in the use of syntax.

Thanks . . . Fred
 
R

Rick B

I would think you would need...

=DateDiff("yyyy",Forms![ClientData]![DOB],Date())+(Format(Forms![ClientData]
![DOB],,"mmdd")>Format(Date(),"mmdd"))



But again, I have not tried that.
Rick B


Fred Worthington said:
Thanks, Rick:

Wow, that was fast! I tried the substitution you suggested but Access will
not accept the expression exactly as I entered it. This is what the
expression looks like now:

=DateDiff("yyyy",[Forms![ClientData]!DOB,Date())+(Format([DOB],"mmdd")>Forma
t(Date(),"mmdd"))

Unfortunately this results in the dread #Name? symbol in the Age field.
Perhaps you can help me revise this expression to achieve the desired result
(where ClientData is the Form that contains the DOB field).

Thanks . . . Fred


Rick B said:
I think you would simply replace [DOB] with the following...

Forms![MyFormName]![MyFieldName]





Fred Worthington said:
Greetings:

I am calculating AGE from the DOB field by using the following expression:
=DateDiff("yyyy",[DOB],Date())+(Format([DOB],"mmdd")>Format(Date(),"mmdd"))
 
F

Fred Worthington

Rick,

That did the trick! Thanks a million for your help.

Fred


Rick B said:
I would think you would need...

=DateDiff("yyyy",Forms![ClientData]![DOB],Date())+(Format(Forms![ClientData]
![DOB],,"mmdd")>Format(Date(),"mmdd"))



But again, I have not tried that.
Rick B


Fred Worthington said:
Thanks, Rick:

Wow, that was fast! I tried the substitution you suggested but Access will
not accept the expression exactly as I entered it. This is what the
expression looks like now:
=DateDiff("yyyy",[Forms![ClientData]!DOB,Date())+(Format([DOB],"mmdd")>Forma
t(Date(),"mmdd"))

Unfortunately this results in the dread #Name? symbol in the Age field.
Perhaps you can help me revise this expression to achieve the desired result
(where ClientData is the Form that contains the DOB field).

Thanks . . . Fred


Rick B said:
I think you would simply replace [DOB] with the following...

Forms![MyFormName]![MyFieldName]





Greetings:

I am calculating AGE from the DOB field by using the following expression:
=DateDiff("yyyy",[DOB],Date())+(Format([DOB],"mmdd")>Format(Date(),"mmdd"))
 

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