Results 1 to 2 of 2
  1. #1
    Join Date
    Mar 2003

    Unanswered: Need to change a box colour if chkbox = true

    I have a report which i am trying to format, I want every other row's details to alternate colour which i have done (See below)

    I also have on my report, a checkbox and a text feild (not sure if i could use a rectangle and format that instead , it doesn't do anything i just need it to change colour)

    chkbox name = "chkClean"
    Text box name = "txtclean"

    I just want the back colour to go red if the check box is true and white if the check box is false

    Please help


    Option Compare Database
    Option Explicit
    Private m_RowCount As Long
    Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
    m_RowCount = m_RowCount + 1
        If m_RowCount / 2 = CLng(m_RowCount / 2) Then
                Me.Detail.BackColor = 15263976 'Change value to the color you desire
                Me.Detail.BackColor = 14811135 'Change value to the color you desire
        End If
    If Me.chkClean = "True" Then
     txtclean.BackColor = 255
     txtclean.BackColor = FFFF66
    End If
    End Sub

  2. #2
    Join Date
    May 2005
    Does it need to change as the check box is clicked? If so, just put the following on the On Click event of the check box:
    If Me.chkClean Then
       Me.txtclean.BackColor = vbRed
       Me.txtclean.BackColor = vbWhite
    End If
    Alternatively, just get rid of the quotes around the True. Me.chkClean = True and me.chkClean are the same boolean statement.
    Me.Geek = True

Posting Permissions

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