How do I calculate an age from a birthdate

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am using the control source =Int(DateDiff("d",[dob],date(),1,1)/365.25) on
a form I created using a query for data entry.

I got this Control Source from this group.

It works on other forms I've created. It also works on all reports I've
created.

On this particular form I keep getting an error "You tried to run a Visual
Basic procedure that improperly references a property or method of an object.

I'm not very VB savy. What am I doing wrong on this particular form, and
not on the others? How do I troubleshoot this mess?
 
This is WRONG!!! There are not 365.25 days in a year.

Use...


DateDiff("yyyy",[Birthdate],Date())+(Format([Birthdate],"mmdd")>Format(Date(
),"mmdd"))
 
Actually, I tried using your formula first, and I found this one also posted
here. I figured it would suit my purposes if I could get it to work. I
posted it, since it was the last one I tried.

The issue isn't the actual calculation as much as that I can't get anything
to work on the particular form I want it to appear on. I keep getting this
error.

I have looked at all of the properties settings on this particular form, and
they are identical to the other forms I am able to use the formula on. I
even build a duplicate form using the same query and everything, and the
formula works on it.

I put a lot of work into the original form. Is there a way to troubleshoot
this so I don't have to start over?

Rick B said:
This is WRONG!!! There are not 365.25 days in a year.

Use...


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







Randy Riley said:
I am using the control source =Int(DateDiff("d",[dob],date(),1,1)/365.25) on
a form I created using a query for data entry.

I got this Control Source from this group.

It works on other forms I've created. It also works on all reports I've
created.

On this particular form I keep getting an error "You tried to run a Visual
Basic procedure that improperly references a property or method of an object.

I'm not very VB savy. What am I doing wrong on this particular form, and
not on the others? How do I troubleshoot this mess?
 
You say you do not have this issue on other forms in your project.
Just a hunch but could the Source and the Name of the subject Control on
the problem form be the same? (as often occurs with an auto-created
bound control)

If so, rename your control (e.g. "txt[Source]") and any reference to
that control in any code and try again.
HTH.
WSF


Randy said:
Actually, I tried using your formula first, and I found this one also posted
here. I figured it would suit my purposes if I could get it to work. I
posted it, since it was the last one I tried.

The issue isn't the actual calculation as much as that I can't get anything
to work on the particular form I want it to appear on. I keep getting this
error.

I have looked at all of the properties settings on this particular form, and
they are identical to the other forms I am able to use the formula on. I
even build a duplicate form using the same query and everything, and the
formula works on it.

I put a lot of work into the original form. Is there a way to troubleshoot
this so I don't have to start over?

:

This is WRONG!!! There are not 365.25 days in a year.

Use...


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







I am using the control source =Int(DateDiff("d",[dob],date(),1,1)/365.25)
on

a form I created using a query for data entry.

I got this Control Source from this group.

It works on other forms I've created. It also works on all reports I've
created.

On this particular form I keep getting an error "You tried to run a Visual
Basic procedure that improperly references a property or method of an
object.

I'm not very VB savy. What am I doing wrong on this particular form, and
not on the others? How do I troubleshoot this mess?
 
Back
Top