DATEMODIFIED FIELD

  • Thread starter Thread starter BajaGeary
  • Start date Start date
B

BajaGeary

I am trying to use the follow code in the before update properties to enter
the date a record has been changes. NO WORKIE!
WHY?
Private Sub OLEBound230_BeforeUpdate(Cancel As Integer)
'Private Sub Form_BeforeUpdate(Cancel As Integer)
On Error GoTo BeforeUpdate_Err

' Set bound controls to system date and time.
DateModified = Date
TimeModified = Time()

BeforeUpdate_End:
Exit Sub

BeforeUpdate_Err:
MsgBox Err.Description, vbCritical & vbOKOnly, _
"Error Number " & Err.Number & " Occurred"
Resume BeforeUpdate_End
End Sub
 
You would normally use the Forms BeforeUpdate event for this. Assuming that
DateModified and TimeModified are fields that exist in the Recordset of the
form, then the following should work. Personally, I prefer to use a single
field (Modified) and use the Now() function to fill it with both date and
time information.

Private Sub Form_BeforeUpdate(Cancel As Integer)
On Error GoTo BeforeUpdate_Err

' Set bound controls to system date and time.
me.DateModified = Date
me.TimeModified = Time()

BeforeUpdate_End:
Exit Sub

BeforeUpdate_Err:
MsgBox Err.Description, vbCritical & vbOKOnly, _
"Error Number " & Err.Number & " Occurred"
Resume BeforeUpdate_End
End Sub
 
Back
Top