Results 1 to 6 of 6
  1. #1
    SSgtBarry is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2014
    Location
    Yuma, AZ
    Posts
    17

    Label.Forecolor

    I use to be able to make a labe.forecolor change (in access 2003) when another object property change. Example:

    If a CheckBox = true then
    Lable1.forcolor = .88888


    else label.forcolor = .22222.
    End if

    In the newer Access, the color codes are "#C0C0C0" or "#EB15C etc.

    The old code doesn't work. What can I use in the newer Access?

  2. #2
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    You can't have a decimal in front of the number.
    I converted the numbers you gave from Hex to Decimal and the code works.

    #EB15C should be #0EB15C (three groups of 2)

    #0EB15C = RGB(12, 177, 92) = 12632256
    #C0C0C0 = RGB(192, 192, 192) = 6074536

    This is the code I used to check the colors
    Code:
    Private Sub Check13_Click()
        Dim Color1 As Long
        Dim Color2 As Long
    
        Color1 = RGB(12, 177, 92)
        Color2 = RGB(192, 192, 192)
        If Me.Check13 Then
            Me.Case_name_Label.ForeColor = Color1
        Else
            Me.Case_name_Label.ForeColor = Color2
            
        End If
    End Sub
    You can use:
    Me.Case_name_Label.ForeColor = Color1 (Color1 set in code)
    or
    Me.Case_name_Label.ForeColor = RGB(12, 177, 92)
    or
    Me.Case_name_Label.ForeColor = 12632256


    If you want colors 88888 and 22222, don't use the decimals in front or behind the numbers
    Code:
    Private Sub Check13_Click()
    
        If Me.Check13 Then
            Me.Case_name_Label.ForeColor = 88888
        Else
            Me.Case_name_Label.ForeColor = 22222       
       End If
    End Sub

  3. #3
    SSgtBarry is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2014
    Location
    Yuma, AZ
    Posts
    17
    Awesome! Thank you very much!!!

  4. #4
    SSgtBarry is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2014
    Location
    Yuma, AZ
    Posts
    17
    I'm still a little confused. The colors I want to use are #ED1C24 and #BFBFBF.

    "In an old project" this is the code I used to change a fore.color of a label:

    If [Discount] = 1 Then
    Label471.ForeColor = -2147483630
    Else: Label471.ForeColor = 8421504
    End If


    With the newer color codes that Access uses, I don't get results but instead errors.

    "How can I convert the newer codes by myself" for all future uses?

    Also: what are the translations of the two colors that I want to use?

    Please!!!! and Thanks!

  5. #5
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,630
    #ED1C24 appears to be a reddish hue (#FF0000 is pure red) - RGB(237,28,36)

    Can discover the RGB codes by setting property of textbox then opening the color palette Custom tab.

    #BFBFBF = RGB(191,191,191)

    Lots of sources on web for color charts http://www.cloford.com/resources/colours/500col.htm

    The property field will accept either the Hex or Access code.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  6. #6
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    I fixed your code and it works. My check box control name is Check26
    Code:
    Private Sub Check26_Click()
        If Me.Check26 Then
            Me.Label24.ForeColor = -2147483630
        Else
            Me.Label24.ForeColor = 8421504
        End If
    End Sub

    If your check box name is "Discount", then you should use
    Code:
        If Me.Discount = True Then
            Label471.ForeColor = -2147483630
        Else   ' do not use the colon here
            Label471.ForeColor = 8421504
        End If

    You could use
    Code:
    If Me.Discount = -1 Then
    since by definition in Access by MS
    TRUE = -1 and
    FALSE = 0.

    BTW, in Excel,
    TRUE = 1 and
    FALSE = 0.

    In actuality,
    FALSE = 0 and
    TRUE = Not FALSE.... which means any non zero number.


    If you want to test it, bind a check box control to a number field. Enter records of 0, -1, 1000, -5000.
    I use this to create reports where I don't want to display the $ amount, but indicate that that they have a value in the field.


    The colon ( : ) was used in the past to allow multiple statements on one line. It use has been deprecated.
    In VBA I have only seen its use as a label indicator in code, mostly in Error handling code to indicate where to go when an error occurs.
    Last edited by June7; 08-21-2014 at 06:00 PM.

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

Similar Threads

  1. Replies: 1
    Last Post: 04-25-2014, 11:41 AM
  2. Replies: 1
    Last Post: 06-18-2013, 12:23 PM
  3. Replies: 2
    Last Post: 10-19-2011, 03:21 AM
  4. Label report
    By Gavroche in forum Reports
    Replies: 1
    Last Post: 10-18-2011, 08:44 PM
  5. Label Help
    By rcotero in forum Access
    Replies: 2
    Last Post: 11-05-2010, 01:39 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