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. :)
 

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

Back
Top