Change text color after a update

  • Thread starter Thread starter Raj
  • Start date Start date
R

Raj

I have a database that we use for scheduling jobs and I
need to know if there is a way to have the text color
changed on any items on a form when a item has been
updated. I dont need to know what the change was just
that is had been updated and a way to capture the userid
and date that made changes to the item?
Thanks in advance
 
I have a database that we use for scheduling jobs and I
need to know if there is a way to have the text color
changed on any items on a form when a item has been
updated. I dont need to know what the change was just
that is had been updated and a way to capture the userid
and date that made changes to the item?
Thanks in advance

Here is some code I have used to change the back color of a textbox
after is has been updated. Call this function in the After Update
event of the textbox. (If this is the only code you will be using
there, then you can select all of the textboxes and in the After
Update of the properties window puy =IndicateEdit()
Watch for word wrap!
-------------------------------------------------------------
Public Function IndicateEdit(Optional lngColor As Long = 14342874) As
Boolean
'Changes the back color (to light grey by default) and back style
'of a text box to normal, ie not transparent. Intended to be used in
'the after update event for the control.
On Error GoTo Err_this

Screen.ActiveControl.Backcolor = lngColor
Screen.ActiveControl.BackStyle = 1

IndicateEdit = True

Exit_this:
Exit Function
Err_this:
MsgBox Err.Number & ", " & Err.Description
Resume Exit_this
End Function
---------------------------------------------------------
This code will restore the controls back to where they were - change
colors to your needs. Call from the form's Current event.
-------------------------------------------------------
Public Sub ResetCtls(strName As String, Optional lngColor As Long =
11333375)
'Sets the back color (to a sandy yellow by default) and back style
'of text and combo boxes to transparent.
On Error GoTo Err_this

Dim ctl As Control
Dim frm As Form

Set frm = forms(strName)
For Each ctl In frm.Controls
If ctl.ControlType = acTextBox Or _
ctl.ControlType = acComboBox Then
ctl.Backcolor = lngColor
ctl.BackStyle = 0
End If
Next ctl
Set frm = Nothing

Exit_this:
Exit Sub
Err_this:
MsgBox Err.Number & ", " & Err.Description
Resume Exit_this

End Sub
 
Jim,
Thank you, this is what I was looking for..
-----Original Message-----


Here is some code I have used to change the back color of a textbox
after is has been updated. Call this function in the After Update
event of the textbox. (If this is the only code you will be using
there, then you can select all of the textboxes and in the After
Update of the properties window puy =IndicateEdit()
Watch for word wrap!
--------------------------------------------------------- ----
Public Function IndicateEdit(Optional lngColor As Long = 14342874) As
Boolean
'Changes the back color (to light grey by default) and back style
'of a text box to normal, ie not transparent. Intended to be used in
'the after update event for the control.
On Error GoTo Err_this

Screen.ActiveControl.Backcolor = lngColor
Screen.ActiveControl.BackStyle = 1

IndicateEdit = True

Exit_this:
Exit Function
Err_this:
MsgBox Err.Number & ", " & Err.Description
Resume Exit_this
End Function
---------------------------------------------------------
This code will restore the controls back to where they were - change
colors to your needs. Call from the form's Current event.
-------------------------------------------------------
Public Sub ResetCtls(strName As String, Optional lngColor As Long =
11333375)
'Sets the back color (to a sandy yellow by default) and back style
'of text and combo boxes to transparent.
On Error GoTo Err_this

Dim ctl As Control
Dim frm As Form

Set frm = forms(strName)
For Each ctl In frm.Controls
If ctl.ControlType = acTextBox Or _
ctl.ControlType = acComboBox Then
ctl.Backcolor = lngColor
ctl.BackStyle = 0
End If
Next ctl
Set frm = Nothing

Exit_this:
Exit Sub
Err_this:
MsgBox Err.Number & ", " & Err.Description
Resume Exit_this

End Sub
--------------------------------------------------------- --------
For user names just call CurrentUser function in before update.
(assuming you are using Group/User security.)

- Jim

.
 
Back
Top