Results 1 to 2 of 2
  1. #1
    azhar2006's Avatar
    azhar2006 is offline Expert
    Windows 7 32bit Access 2010 32bit
    Join Date
    Mar 2012
    Posts
    528

    change color of a buttons

    Hello guys
    I try to change the color of the buttons. Based on the value of a text box, and used this code but did not succeed to do so.


    Code:
    Private Sub Form_Load()
    If Me.text = 1 Then
    Me.Button1.ForeColor = RGB(170, 0, 0)
    Else
    Me.text = 2
    Me.Button2.ForeColor = RGB(225, 0, 0)
    Me.text = 3
    Me.Button3.ForeColor = RGB(222, 0, 0)
    End If
    
    
    End Sub
    Any help
    Thanks in advance

  2. #2
    amrut is offline Expert
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2012
    Location
    India
    Posts
    616
    Are you missing the elseif ?
    Code:
    Private Sub Form_Load()
    If Me.text = 1 Then
    Me.Button1.ForeColor = RGB(170, 0, 0)
    ElseIf Me.text = 2 Then
    Me.Button2.ForeColor = RGB(225, 0, 0)
    ElseIf Me.text = 3 Then
    Me.Button3.ForeColor = RGB(222, 0, 0)
    End If
    
    
    End Sub

Please reply to this thread with any new information or opinions.

Similar Threads

  1. VBA to change font color
    By data808 in forum Access
    Replies: 5
    Last Post: 10-23-2014, 11:10 AM
  2. Replies: 14
    Last Post: 02-19-2013, 11:48 AM
  3. Change Change FormHeader Color
    By burrina in forum Forms
    Replies: 4
    Last Post: 12-19-2012, 08:18 PM
  4. Text box change color
    By Ray67 in forum Forms
    Replies: 14
    Last Post: 11-19-2012, 04:06 PM
  5. change cell color
    By bishop743 in forum Programming
    Replies: 0
    Last Post: 02-01-2009, 11:00 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums