Results 1 to 11 of 11
  1. #1
    Lounger
    Join Date
    Jul 2002
    Posts
    37
    Thanks
    0
    Thanked 0 Times in 0 Posts

    DateDiff Function

    Okay now, I'm really frustrated. I'm using Access 97 and I've used the following statement in a form before and it worked no problem. I have the Patient DOB field in the table and in the form I want to show their age. When I try the exact same thing in another database, I get the #Name? error. The Patient DOB is in the table and the spelling is correct. The text box I am entering this statement in is an unbound text box (I don't need to keep the data).

    =DateDiff("d",[Patient DOB],Now())

    What am I doing wrong? <img src=/S/hairout.gif border=0 alt=hairout width=31 height=23>

  2. #2
    3 Star Lounger
    Join Date
    Dec 2000
    Location
    Manassas, Virginia, USA
    Posts
    363
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: DateDiff Function

    Your calculation will show the number of days old the person is. If you format your answer as Integer and divide the total days by 365.25 you should get their age in years.

    =Int(DateDiff("d",[Patient DOB],Now())/365.25)
    Judy Jones, Computer Training Specialist
    Manassas, Virginia

  3. #3
    Lounger
    Join Date
    Jul 2002
    Posts
    37
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: DateDiff Function

    That isn't the problem. The problem is that I'm getting the #name? error in the form.

  4. #4
    4 Star Lounger
    Join Date
    Dec 2000
    Location
    London, Ontario, Canada
    Posts
    437
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: DateDiff Function

    There's nothing wrong with the expression you're using. I assume you've checked all the obvious suspects. Try adding [Patient DOB] to the form just to double check there is a valid date. The only other possibility is a circular reference, i.e. you would get a #Name? error if the name of the control containing this expression is Patient DOB.

  5. #5
    Lounger
    Join Date
    Jul 2002
    Posts
    37
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: DateDiff Function

    The Patient DOB is in the form formatted as a Medium date and it looks fine. I tried your suggestion and changed the name of the DateDiff box to "Test" and I still got the same error.

    Anything else you can suggest?

  6. #6
    Uranium Lounger
    Join Date
    Jan 2001
    Location
    South Carolina, USA
    Posts
    7,295
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: DateDiff Function

    I don't see anything obvious wrong with your statement if Patient DOB is the correct filed name. Have you tried deleting and retyping the statement just in case there is something not obvious hiding in there. You might also try changing to a field name that does not contain a blank which I have seen cause some wierd problems.
    Legare Coleman

  7. #7
    5 Star Lounger
    Join Date
    Jan 2001
    Location
    Newbury, Berkshire, England
    Posts
    712
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: DateDiff Function

    I just bunged it in a form to test it, it works ok for me too!!!

    The formula

  8. #8
    WS Lounge VIP rory's Avatar
    Join Date
    Dec 2000
    Location
    Burwash, East Sussex, United Kingdom
    Posts
    6,280
    Thanks
    3
    Thanked 191 Times in 177 Posts

    Re: DateDiff Function

    Hi,
    Clutching at straws a bit now, but is the [Patient DOB] field in a subform on your form?
    Regards,
    Rory

    Microsoft MVP - Excel

  9. #9
    Lounger
    Join Date
    Jul 2002
    Posts
    37
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: DateDiff Function

    No it isn't. It's pulling the DOB right from the table.

  10. #10
    4 Star Lounger
    Join Date
    Dec 2000
    Location
    London, Ontario, Canada
    Posts
    437
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: DateDiff Function

    A little more straw clutching here. Check for missing references. Post if you need help doing that.

  11. #11
    Lounger
    Join Date
    Jul 2002
    Posts
    37
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: DateDiff Function

    IT'S FIXED. I'm not sure which action did it, however, I repaired (by accident actually), then compacted (my original intention). When I went back to look at the form, my age was there.

    Thank you all so much for your help!!!!!!! <img src=/S/thumbup.gif border=0 alt=thumbup width=15 height=15>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •