Results 1 to 7 of 7
  1. #1
    Lucas237 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2016
    Posts
    4

    Change color


    HelloI have question, how I can change automatically label color? the color of the label is dependent on the values in the table.thank you very much in advance.
    Attached Thumbnails Attached Thumbnails t?o.png  
    Attached Files Attached Files

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,524
    You can't do it with continuous forms. EVERY label will get the same color.
    but the code is in the ONCURRENT event:
    Code:
    sub Form_oncurrent()
    select case txtBox
        Case "bob"
             VColor = vbRed
         Case "Sally"
              VColor = vbBlue
    end select
    label.forecolor = VColor

  3. #3
    Micron is offline Virtually Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,791
    The forms in your sample db are not continuous, so depending on some result, you set the backcolor as already suggested, or use a construct like
    If SomeConditionIsMet Then Me.Etykieta1.Backcolor = vbGreen
    You say it depends on data values, but I can't tell from what or how by your sample since labels cannot have data associated with them. Your picture doesn't help me.
    P.S. watch for any failure that might occur in further development from your inconsistent spelling of Workplace.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  4. #4
    Lucas237 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2016
    Posts
    4
    So, how can I connect specific value with specific label, and then the values in the table change color automatically?

  5. #5
    Micron is offline Virtually Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,791
    From what I've seen in your db, I see no reason to use a label. If you used a textbox control instead, you could use conditional formatting on it to set the color (if the control's data met your criteria). In order for you to color a label, you'd need a control on the form to supply the data, then have some event such as your label click to check the control value and set the color accordingly. If you're going to add a control anyway, I see no sense in having both. Of course, the form would need a record source and the controls would need a control source (as bound controls in your design scheme) OR the control source could be a DLookup if they must be unbound.
    Other than that, I don't know what else to tell you because you've still not divulged much about what's behind this and what the process is.
    Last edited by Micron; 07-30-2016 at 01:31 PM. Reason: clarification

  6. #6
    Lucas237 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2016
    Posts
    4
    So, I should use the texbox for every workplace on the "workplace map"? and what do next in the textbox?
    It will be db with form "Workplace Map" and when you open it, you will see all the workplaces (map will be bigger than now) missing the computer, and additionally when you press some workplace you go to next form when you can check PC parameters.

  7. #7
    Micron is offline Virtually Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,791
    As I tried to say In post #3 I don't know enough about what you are doing to answer. Maybe a more sensible approach is to have a combo box with a list from which you choose then display the related information. You will have to provide more info on the process; what that is and what you want to achieve.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

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

Similar Threads

  1. Change Color Within a String
    By thexxvi in forum Access
    Replies: 3
    Last Post: 05-25-2016, 06:33 AM
  2. change tab color or header color
    By witz07 in forum Access
    Replies: 6
    Last Post: 03-31-2016, 05:31 PM
  3. change color of a buttons
    By azhar2006 in forum Forms
    Replies: 1
    Last Post: 10-29-2014, 06:15 AM
  4. VBA to change font color
    By data808 in forum Access
    Replies: 5
    Last Post: 10-23-2014, 11:10 AM
  5. Change Change FormHeader Color
    By burrina in forum Forms
    Replies: 4
    Last Post: 12-19-2012, 08:18 PM

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