Formula Not working in Query

G

Guest

The formula below works when it is in the OnUpdate event of a form where I
add new patients. I've come to relize that this way the pt will remain the
same age forever as once they have been entered the record will never be
updated again.

So I tried it in the OnCurrent event of my main patient form and I get a msg
saying that the procedure is not allowed.

Since I've been seeking help here I have also come to realize I never want
to store a calculated value in a field. So I tried the below in a query and I
get a syntax error.

Any help with this would be greatly appreciated.

Thanks, Rob


Age = DateDiff("yyyy", [DOB], Now()) + _
Int(Format(Now(), "mmdd") < Format([DOB], "mmdd"))
 
G

Guest

Try this in you query:

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

Watch the word wrapping.
 
G

Guest

Thanks, worked like a charm. Have a great week. Rob

Mr B said:
Try this in you query:

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

Watch the word wrapping.
--
HTH

Mr B


RobUCSD said:
The formula below works when it is in the OnUpdate event of a form where I
add new patients. I've come to relize that this way the pt will remain the
same age forever as once they have been entered the record will never be
updated again.

So I tried it in the OnCurrent event of my main patient form and I get a msg
saying that the procedure is not allowed.

Since I've been seeking help here I have also come to realize I never want
to store a calculated value in a field. So I tried the below in a query and I
get a syntax error.

Any help with this would be greatly appreciated.

Thanks, Rob


Age = DateDiff("yyyy", [DOB], Now()) + _
Int(Format(Now(), "mmdd") < Format([DOB], "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