Katherine said:
Hey is there any way to change the colour of a text box to start off
as red text then change to black when the field is updated or
entered? I want to open a form with a record for data input with a
default date that is red and changes to black when it has been
clicked on or changed?
Thanks
You could use the On Got Focus and On Lost Focus events if you want it to
change to when the cursor is in it and then change back when the cursor is
somewhere else.
Private Sub FieldName_GotFocus()
Me![FieldName].ForeColor = 0 'this is black text
End Sub
Private Sub FieldName_LostFocus()
Me![FieldName].ForeColor = 255 'this is red text
End Sub
If you want it to change after it's been changed then:
Private Sub FieldName_Change()
Me![FieldName].ForeColor = 0 'this is black text
End Sub
If you want it to change when edited and stay changed unless the original
string is re-entered, dim a variable as the data type of the text box and
set its value to the initial value of the text box like
dim initvalue as <whatever>
initvalue = [fieldname]
then you can test for the change in the form's oncurrent event like:
if [fieldname] <> initvalue then
Me![FieldName].ForeColor = 0
else Me![FieldName].ForeColor = 255
end if