Re: Data Update
Hi
I am trying to create a pop up box which will highlight some change has been done on a record and at the same time save the date and time it took place. The code is as follows;
Private Sub Form_BeforeUpdate(Cancel As Integer)
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
Forms![StudentDetails1].txtlastupdated = Now() '<<< Use NOW to get the date and time
End If
End If
End Sub
This works perfectly with the date and time. Whenever a field is updated in the main form or sub-form the date and time is recorded.
However, the problem I am facing now is that when a field is changed in the main form and when the pop box comes saying;
Confirm
Data will be modified, Are you sure?
Yes No
When I select No, the following is shown
"The DoMenuItem action was Cancelled"
and changed field remains the same, instead of going back to its original form.
With subform it is an entirely different scenario it will never let you do anything else unless you accept the change, which in other occassions you won't want to.
i.e., the pop box keeps popping when you select NO until you select YES and the change is made.
Whats the problem with the syntax.
Thank you.
Hi
I am trying to create a pop up box which will highlight some change has been done on a record and at the same time save the date and time it took place. The code is as follows;
Private Sub Form_BeforeUpdate(Cancel As Integer)
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
Forms![StudentDetails1].txtlastupdated = Now() '<<< Use NOW to get the date and time
End If
End If
End Sub
This works perfectly with the date and time. Whenever a field is updated in the main form or sub-form the date and time is recorded.
However, the problem I am facing now is that when a field is changed in the main form and when the pop box comes saying;
Confirm
Data will be modified, Are you sure?
Yes No
When I select No, the following is shown
"The DoMenuItem action was Cancelled"
and changed field remains the same, instead of going back to its original form.
With subform it is an entirely different scenario it will never let you do anything else unless you accept the change, which in other occassions you won't want to.
i.e., the pop box keeps popping when you select NO until you select YES and the change is made.
Whats the problem with the syntax.
Thank you.