View Full Version : Updating Field using DateDiff


spalmateer
01-10-2001, 11:18 PM
Hi,
I have two fields on my form. One is Unit Installed and the other is Unit Age. I would like to use VB to update the Unit Age field after entering a date into Unit Installed. I'm using this expression to find the age: =DateDiff("yyyy",[Unit Installed],Now())+Int(Format(Now(),"mmdd")<Format([Unit Installed],"mmdd")). Thanks for any help and insight!
Scott

ntp
01-11-2001, 08:19 AM
I'm not sure if this is what you're asking but ry this:

Private sub txtUnitInstalled_AfterUpdate()
me.txtUnitAge = ' put your expression here.
End Sub

As the user enters a date value into the txtUnitInstalled control, this event procedure will be fired which will cause the text in the tex tcontrol "txtUnitAge" to become the value of your expression.

ntp