Hi all, I currently have the code below on a form. The before update code is there to prevent alarms being entered at the same times and works perfectly.
However, the 'ResetComputerName' button is just to change the computer name associated with the alarm. It works as intended, and it doesn't change the alarm time so I don't need to check for duplicates etc, but the beforeupdate code prevents it from saving as it recognises the alarm time as being one that is already set.
How could I change/workaround the code to allow changes to be made the txtComputerName?
Many thanks in advance!
Code:
Private Sub btnReschedule_Click()
Call GetDate([Form]![txtCommentAlarm], 0)
End Sub
Private Sub btnResetComputerName_Click()
If MsgBox("This will reset the computer name which will show the alarm to this Computer. Are you sure?", vbOKCancel, "Warning") = vbOK Then
Me![txtComputerName] = Environ("Computername")
End If
End Sub
Private Sub Form_BeforeUpdate(Cancel As Integer)
If DCount("*", "tblCustomerComments", "[CommentAlarm]= #" & Format(Me![txtCommentAlarm], "mm\/dd\/yyyy hh:nn") & "#") > 0 Then ' It is a duplicate
Cancel = True
MsgBox "Sorry an alarm has already been set at this Date/Time, please enter a different Date/Time"
Me.Undo '<----Remove this if you don't want to erase form input
End If
End Sub
However, the 'ResetComputerName' button is just to change the computer name associated with the alarm. It works as intended, and it doesn't change the alarm time so I don't need to check for duplicates etc, but the beforeupdate code prevents it from saving as it recognises the alarm time as being one that is already set.
How could I change/workaround the code to allow changes to be made the txtComputerName?
Many thanks in advance!