View Single Post
  #4  
Old July 14th, 2009, 09:02 PM posted to microsoft.public.access.forms
Jeff Boyce
external usenet poster
 
Posts: 8,621
Default Calculating age in a form

When you are referring to a field in a table from within a form, you either
need to have that table as part of the source for the form, or you need to
use something like the DLookup() function to "see" that value.

If you are referring to a control on a form (from within a form), you need
to tell Access to look in that form, with something like:
Forms!YourSourceForm!YourControl

The simpler version of this happens when you refer to a control on the SAME
form as you're in. Then you can use:
Me!YourControl

Check Access HELP for exact syntax on these.

Regards

Jeff Boyce
Microsoft Office/Access MVP

"tm3025" wrote in message
...
Sorry it should [Surgery!Date of Surgery]... Surgery is a table and Date
of
Surgery is a field in that table. Why is it recognizing it in a query, but
not in a form? Does it have to do with the fact that I created this form
from
a different table than Surgery? Thanks for your help.

"Jeff Boyce" wrote:

When Access says "#NAME", its telling you it doesn't recognize the name
you
gave it. Typically this is because the name of the form or the name of
the
control isn't recognized.

I'd look first at Format([X!Date of X] ... is "X" a table name or a form
name?

Regards

Jeff Boyce
Microsoft Office/Access MVP

"tm3025" wrote in message
...
I entered the following expression into the control source of an unbound
text
box on a form. The form was created from a personal info table which
DOB
came
from, but Date of X came from a different table. When I try to enter
this
it,
all I get in the text box is #NAME?

=DateDiff("yyyy", [DOB], Surgery![Date of
X])-IIF(Format([DOB],"mmdd")Format([X!Date of X],"mmdd"),1,0)

My first attempt at this involved a query with the same expression, and
it
returned correct values. However, when I made the field from the query
the
control source of the text box in the form, it also returned #NAME?

I'm guessing there must be something wrong in the way I am going about
this.
Any help would be much appreciated.