I am trying to use 2 simple pieces of code on the same form. They both work on their own but when combined in one form together, one is ignored. Could someone please tell me what’s wrong?
I initially added the code to change the back colour and add a message when a record was being edited.
Private Sub Form_Dirty(Cancel As Integer)
Detail.BackColor = RGB(66, 210, 210)
InfoMessage.Caption = "You have modified this record. " & _
"If you move to another record, your changes will be applied. " & _
"To cancel your changes, hit the Esc key."
End Sub
Private Sub Form_afterUpdate()
Detail.BackColor = vbWhite
InfoMessage.Caption = ""
End Sub
Private Sub Form_Undo(Cancel As Integer)
Detail.BackColor = vbWhite
InfoMessage.Caption = ""
End Sub
I also wanted to have the back colour in red on a particular control with a particular value (already input). This works on its own in another version of the form but when the 2 pieces of code are combined, this is the one that is ‘ignored’:
Private Sub Form_Current()
If Status = "Unsuccessful" Then
Status.BackColor = vbRed
Else
Status.BackColor = vbWhite
End If
End Sub
Thank you in advance.
I initially added the code to change the back colour and add a message when a record was being edited.
Private Sub Form_Dirty(Cancel As Integer)
Detail.BackColor = RGB(66, 210, 210)
InfoMessage.Caption = "You have modified this record. " & _
"If you move to another record, your changes will be applied. " & _
"To cancel your changes, hit the Esc key."
End Sub
Private Sub Form_afterUpdate()
Detail.BackColor = vbWhite
InfoMessage.Caption = ""
End Sub
Private Sub Form_Undo(Cancel As Integer)
Detail.BackColor = vbWhite
InfoMessage.Caption = ""
End Sub
I also wanted to have the back colour in red on a particular control with a particular value (already input). This works on its own in another version of the form but when the 2 pieces of code are combined, this is the one that is ‘ignored’:
Private Sub Form_Current()
If Status = "Unsuccessful" Then
Status.BackColor = vbRed
Else
Status.BackColor = vbWhite
End If
End Sub
Thank you in advance.