DateDiff on an Access form

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

Guest

Hello,
I haven't been doing VBA in a while, so I'm a little rusty. On the "on load"
event of a form, I have the following code, which is supposed to give me the
difference between someone's "hire date" and today, in years. I keep getting
2545, which obviously is wrong. Thanks for any help you can provide.

Private Sub Form_Load()
Dim vOLPTotal
Dim myDate As Date
myDate = Date
Me.Total_OLP_Days.Value = DateDiff("y", Now, Me.Hire_Date.Value)
 
Try:
Me.Total_OLP_Days = DateDiff("yyyy", Date, Me.Hire_Date)

The .Value property is the default property and need not be specified if you
are lazy like me. :)
 
Back
Top