C
chancer
I have a form for maintaining address and contact details of a bunch of
people and have used VBA to change the background color of any cells that
have been edited.
When the changes are saved or undone the background color is returned to
white
Below is how I did it and it seems very longwinded - is there a more elegant
way of achieving the same result?
thanks
chancer
---
Private Sub txtName_Dirty(Cancel As Integer)
Me.txtName.BackColor = vbYellow
End Sub
Private Sub txtShortName_Dirty(Cancel As Integer)
Me.txtShortName.BackColor = vbYellow
End Sub
Private Sub txtAddress1_Dirty(Cancel As Integer)
Me.txtAddress1.BackColor = vbYellow
End Sub
Private Sub txtAddress2_Dirty(Cancel As Integer)
Me.txtAddress2.BackColor = vbYellow
End Sub
etc
---
Private Sub Form_BeforeUpdate(Cancel As Integer)
If MsgBox("Do you want to save the changes?", vbYesNo, "Confirm Change")
= vbNo Then
Cancel = True
Me.Undo
Me.txtName.BackColor = vbWhite
Me.txtShortName.BackColor = vbWhite
Me.txtAddress1.BackColor = vbWhite
Me.txtAddress2.BackColor = vbWhite
etc
end if
End sub
---
Private Sub Form_AfterUpdate()
Me.txtName.BackColor = vbWhite
Me.txtShortName.BackColor = vbWhite
Me.txtAddress1.BackColor = vbWhite
Me.txtAddress2.BackColor = vbWhite
etc
End sub
people and have used VBA to change the background color of any cells that
have been edited.
When the changes are saved or undone the background color is returned to
white
Below is how I did it and it seems very longwinded - is there a more elegant
way of achieving the same result?
thanks
chancer
---
Private Sub txtName_Dirty(Cancel As Integer)
Me.txtName.BackColor = vbYellow
End Sub
Private Sub txtShortName_Dirty(Cancel As Integer)
Me.txtShortName.BackColor = vbYellow
End Sub
Private Sub txtAddress1_Dirty(Cancel As Integer)
Me.txtAddress1.BackColor = vbYellow
End Sub
Private Sub txtAddress2_Dirty(Cancel As Integer)
Me.txtAddress2.BackColor = vbYellow
End Sub
etc
---
Private Sub Form_BeforeUpdate(Cancel As Integer)
If MsgBox("Do you want to save the changes?", vbYesNo, "Confirm Change")
= vbNo Then
Cancel = True
Me.Undo
Me.txtName.BackColor = vbWhite
Me.txtShortName.BackColor = vbWhite
Me.txtAddress1.BackColor = vbWhite
Me.txtAddress2.BackColor = vbWhite
etc
end if
End sub
---
Private Sub Form_AfterUpdate()
Me.txtName.BackColor = vbWhite
Me.txtShortName.BackColor = vbWhite
Me.txtAddress1.BackColor = vbWhite
Me.txtAddress2.BackColor = vbWhite
etc
End sub