Easy Answer - Stupid Person

feets

Registered User.
Local time
Today, 23:21
Joined
Jan 4, 2007
Messages
12
All I want to do is a create function that checks the text in a form field, and then dependant on value assign a font color. So my code I was thinking would look something like this

Dim txt As textBox

set txt = txtBoxName

FormatTxtBox(txtBoxName)

Public Function FormatTxtBox(txt As TextBox)

If txt.text="Not Available" Then
txt.foreColor="Red"
end if


End Function

I just get a runtime error 424 Object required??

Pls Help
 
You need a Me. to reference the form the control is on. Cant you use conditional formatting for this?
 
keith is right. you can use conditional formating. itll save u a coding hassle!!
 
I could use conditional formatting in this case, but I thought it would be maybe useful to know in the future.
 
I will need to use code by the looks of it. Conditional formatting only allows for three possible answers, I have 10. So I still need help
 
You will need something like below in your On_Current Event of the form.



Dim lngRed as long, lngBlack as Long, LngYellow as long,lngWhite as long



lngRed = RGB(255, 0, 0)
lngBlack = RGB(0, 0, 0)
lngYellow = RGB(255, 255, 0)
lngWhite = RGB(255, 255, 255)

Select Case me.TextBoxName

Case is=”Value1”
Me.TextBoxName.forecolor=lngRed
Case is=”Value2”
Me.TextBoxName.Forecolor=lngWhite
Case is=”Value3”
Me.TextBoxName.forecolor=lngYellow
Case Else
Me.TextBoxName.forecolor=lngBlack
End Select
 

Users who are viewing this thread

Back
Top Bottom