Results 1 to 3 of 3
  1. #1
    CraigR is offline Novice
    Windows 10 Access 2016
    Join Date
    Sep 2017
    Posts
    27

    Formatting Text colour on resul

    Hi and thanks for any help provided



    I have a yes/no field. name "Preferred1"
    I then have field. Name "Mobile1"
    & field. Name "Email1"

    I would like to change the font colour for Mobile1 & Email1 from Black to #D8D8D8 if Preferred1 is checked Yes

    Private Sub Prefer1_AfterUpdate()
    If Me.Prefer1 = "No" Then
    Me.Mobile1 = "#D8D8D8" 'Text becomes grey if Prefer1 is not checked
    Me.Email1 = "
    #D8D8D8"
    Else
    If Me.Prefer1 = "Yes" Then
    Me.Mobile1 = "#000000" 'Text stays black If Prefer1 is checked
    Me.Email1 = "
    #000000
    "

    End If
    End Sub


  2. #2
    Micron is offline Very Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,423
    you want to apply any color value to the Forecolor property of the control: Me.Mobile1.Forecolor =
    and I think remove the quotes as the value is not text. You will find it easier to use the RGB method as opposed to the hex value as it has to be tweaked as in
    Val("&H" & "FFFFFF"). You can also use vb color constants like vbGreen.

    Or just use conditional formatting.
    Last edited by Micron; 05-26-2019 at 12:06 PM. Reason: added info
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  3. #3
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    Using VBA to set property will affect all instances of control. So if form is in Continuous or Datasheet, all records will show same color. Use Conditional Formatting.
    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.

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

Similar Threads

  1. Replies: 3
    Last Post: 10-22-2015, 07:15 AM
  2. Changing text box back colour
    By Duncan in forum Forms
    Replies: 3
    Last Post: 02-23-2013, 05:32 PM
  3. Replies: 3
    Last Post: 02-07-2013, 09:53 PM
  4. Changing Text colour on value amount
    By stu_C in forum Forms
    Replies: 1
    Last Post: 08-08-2011, 06:58 AM
  5. Replies: 0
    Last Post: 02-12-2009, 05:23 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