Results 1 to 9 of 9
  1. #1
    2 Star Lounger
    Join Date
    Jul 2005
    Location
    North Carolina, USA
    Posts
    195
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Changing Form Detail Color (2003)

    Hi, Dont know what is going on, that I can not make the code do what it needs to do. I would like the form to change the Detail back color depending on the value of a combo box. The form execute the change after I close and reopen it, instead, of while the field gets update. I tried to put the code on the control afterupdate, under the form afterupdate. on load, etc. cant get to work. Any help.

    Private Sub Form_Current()

    If cobDrop.Value = "trauma" Then
    Me.Detail.BackColor = RGB(255, 44, 0)
    End If

    End Sub

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Changing Form Detail Color (2003)

    Are you sure that the combo box contains text values? Perhaps it has a hidden first column with numeric values.
    Also, you should reset the color if the value is different from the one you check for.
    The code should be both in the Form_Current and in the cobDrop_AfterUpdate event.

  3. #3
    2 Star Lounger
    Join Date
    Jul 2005
    Location
    North Carolina, USA
    Posts
    195
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Re: Changing Form Detail Color (2003)

    Hans,

    Thanks for the help. that did it. it is making the changes just like I want it.

    Private Sub cobDrop_AfterUpdate()
    If cobDrop.Value = "trauma" Then
    Me.Detail.BackColor = RGB(255, 44, 0)

    Else
    Me.Detail.BackColor = RGB(255, 255, 255)
    End If

    End Sub

  4. #4
    2 Star Lounger
    Join Date
    Jul 2005
    Location
    North Carolina, USA
    Posts
    195
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Re: Changing Form Detail Color (2003)

    Sorry to bother, again. The code works fine but I have to select the text value from the list to force the code to recognize the value in the field even though the designated value already exist. When the form loads or when I change view mode It does not recognize the text value of the field prior to kind of updating the field by re-selecting the text value. Any suggestions.

  5. #5
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Changing Form Detail Color (2003)

    Do you have the same code in the Form_Current event?

  6. #6
    2 Star Lounger
    Join Date
    Jul 2005
    Location
    North Carolina, USA
    Posts
    195
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Re: Changing Form Detail Color (2003)

    Indeed. It is changing the color when i select the required text value, but it doesnt do it by recognizing the value on it own. How can i force it to see the value and change automatically.

  7. #7
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Changing Form Detail Color (2003)

    Could you post a stripped down copy of your database? See <post#=401925>post 401925</post#> for instructions.

  8. #8
    2 Star Lounger
    Join Date
    Jul 2005
    Location
    North Carolina, USA
    Posts
    195
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Re: Changing Form Detail Color (2003)

    Hans Here is the stripped version. Everything is working find after I cleaned up all the different codes that were in the form. Do i have to move the code for the event Form_Current to the top of the list.
    Attached Files Attached Files

  9. #9
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Changing Form Detail Color (2003)

    There is no need to move the Form_Current event procedure. I don't know what the problem was before, but the formatting works fine in the sample database.

Posting Permissions

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