Results 1 to 4 of 4
  1. #1
    rmd62163 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jan 2013
    Posts
    17

    evaluating multiple frames to set label back color


    Would there be a easier method then this?
    Code:
    'Pacer frame set to proper background
        If Me.FrmPacer.Value = 1 Then
               Me.LblPacer.BackColor = vbGreen
        ElseIf Me.FrmPacer.Value = 2 Then
               Me.LblPacer.BackColor = vbYellow
        ElseIf Me.FrmPacer.Value = 3 Then
               Me.LblPacer.BackColor = vbRed
        ElseIf Me.FrmPacer.Value = 0 Then
               Me.LblPacer.BackColor = vbWhite
               Me.LblPacer.FontWeight = normal
        ElseIf Me.FrmPacer.Value = Null Then
               Me.LblPacer.BackColor = vbWhite
               Me.LblPacer.FontWeight = normal
               End If
    'neuro frame set to proper background
        If Me.FrmNeuroStim.Value = 1 Then
               Me.LblNeurostim.BackColor = vbGreen
        ElseIf Me.FrmNeuroStim.Value = 2 Then
               Me.LblNeurostim.BackColor = vbYellow
        ElseIf Me.FrmNeuroStim.Value = 3 Then
               Me.LblNeurostim.BackColor = vbRed
        ElseIf Me.FrmNeuroStim.Value = 0 Then
               Me.LblNeurostim.BackColor = vbWhite
               Me.LblNeurostim.FontWeight = normal
        ElseIf Me.FrmNeuroStim.Value = Null Then
               Me.LblNeurostim.BackColor = vbWhite
               Me.LblNeurostim.FontWeight = normal
               End If
    I have multiple frames on one subform that when selected sets a unassociated labels back color. Then when cancelled by undo code the back color stays on the color that it was changed to on afterupdate event from the frame with option controls. I would like to loop thru but could not come up with the proper method if it is even possible. Just looking for a shorter approach. the above code works after refreashed, but just wondering if there is a shorter or more efficient method. Any ideas or different approach would be greatly appreciated

    Thank you for your time.
    Click image for larger version. 

Name:	frame.jpg 
Views:	6 
Size:	9.0 KB 
ID:	16875just a small clip of the form

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,525
    (note: you dont need the ME)

    Set the option button to the color value then after update is all 1 statement

    LblPacer.BackColor = FrmNeuroStim.Value

  3. #3
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,525
    and Case statements are easier to read:

    Code:
    Select Case FrmPacer.Value
               Case 1
                  LblPacer.BackColor = vbGreen
               Case 2
                  LblPacer.BackColor = vbYellow
               Case 3
                  LblPacer.BackColor = vbRed
               Case 4
                  LblPacer.BackColor = vbWhite
               Case Else
    End Select

  4. #4
    rmd62163 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jan 2013
    Posts
    17
    Thanks for the advice ranman, I did notice the Me after I pasted the code and got rid of it. I like the select case and will go with that. Does look a lot easier to read. I give the set option value a try to. Thanks

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

Similar Threads

  1. alternate back color not working
    By dbaldwin117 in forum Reports
    Replies: 3
    Last Post: 02-25-2013, 01:33 PM
  2. Replies: 5
    Last Post: 09-18-2012, 12:39 PM
  3. Form Back Color, screen only?
    By LostInAccess in forum Forms
    Replies: 2
    Last Post: 07-19-2012, 08:39 PM
  4. Back color update issue
    By GraemeG in forum Programming
    Replies: 3
    Last Post: 03-21-2011, 11:32 AM
  5. Replies: 1
    Last Post: 03-29-2009, 08:27 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