Conditional Event Procedure

G

Guest

I have an event procedure for after update that I got to work on one text box
by experimenting on one field in a blank database. Now, how do I modify that
code so that I can call the routine for any other field that has the focus?

Private Sub field1_AfterUpdate()
Dim StatusNumber As Long
StatusNumber = field1.Text
Select Case StatusNumber
Case "0"
field1.ForeColor = 0
field1.BackColor = 0
Case "1"
field1.ForeColor = 12632256
field1.BackColor = 12632256
Case "2"
field1.ForeColor = 65280
field1.BackColor = 65280
..
..
..
End Case
End Sub
 
G

Guest

Do you really want to change the fore and back color to the same values?

You can either pass a value to this subroutine, or use ctrl.value to
determine the value and use that in your select statement.

Public Sub ColorControl(SomeValue)

Dim ctrl as control
set ctrl = Screen.activecontrol

SELECT Case SomeValue
Case 0
ctrl.forecolor = 0
ctrl.backcolor = 0
Case 1
...
Case 2
...

End Select

End Sub

You will need to fill in the values and the information in "..."

HTH
Dale
 
G

Guest

Thanks! And yes I want to change to the same color. I am showing a status
color rather than text for a visual.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top