Results 1 to 3 of 3
  1. #1
    Join Date
    Sep 2003
    Posts
    122

    Unanswered: Change Font Color Based On Value In Text Box

    I know how to change the Font color, but I am not sure what If/Then statement I need to use. I have a TextBox that is based on a stored procedure. Basically, I want the text to be red if the text box contains a "-". Thanks.

  2. #2
    Join Date
    Oct 2003
    Location
    Ger
    Posts
    1,969
    Provided Answers: 1

    Re: Change Font Color Based On Value In Text Box

    Originally posted by shearness
    I know how to change the Font color, but I am not sure what If/Then statement I need to use. I have a TextBox that is based on a stored procedure. Basically, I want the text to be red if the text box contains a "-". Thanks.
    Put the next code in the Form Current event:


    Private Sub Form_Current()
       If InStr(Me.Text0, "_") Then
         Me.Text0.ForeColor = vbBlue
       Else
         Me.Text0.ForeColor = vbBlack
       End If
    End Sub




    Where Text0 is the name of your text Box, required to change its color

  3. #3
    Join Date
    Sep 2003
    Posts
    122
    Thank you. That worked perfectly.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •