Hi,
I want to automatically update date and time when a record is changed or created. I have a form which is also built with a subform. The code am using is shown below: In the Before Event of the Form I have the following code;
If Me.NewRecord Then
If MsgBox("Data will be saved, Are you Sure?", vbYesNo, "Confirm") = vbNo Then
Cancel = True
End If
Else
If MsgBox("Data will be modified, Are you Sure?", vbYesNo, "Confirm") = vbNo Then
Cancel = True
Else
Me.txtLastUpdated = Now() '<<< Use NOW to get the date and time
End If
End If
This works perfectly and updates the Date and time when a field in the form is updated. My problem is when I update any field in the subform the date and time is not updated. I tried to put the code in the before event, but it generates an error.
Any help will be appreciated
I want to automatically update date and time when a record is changed or created. I have a form which is also built with a subform. The code am using is shown below: In the Before Event of the Form I have the following code;
If Me.NewRecord Then
If MsgBox("Data will be saved, Are you Sure?", vbYesNo, "Confirm") = vbNo Then
Cancel = True
End If
Else
If MsgBox("Data will be modified, Are you Sure?", vbYesNo, "Confirm") = vbNo Then
Cancel = True
Else
Me.txtLastUpdated = Now() '<<< Use NOW to get the date and time
End If
End If
This works perfectly and updates the Date and time when a field in the form is updated. My problem is when I update any field in the subform the date and time is not updated. I tried to put the code in the before event, but it generates an error.
Any help will be appreciated