Results 1 to 9 of 9
  1. #1
    mick3911 is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Feb 2013
    Location
    Wirral, UK
    Posts
    66

    Change of Font

    Hi All,
    I have a form that has a combo box that contains a listconsisting of ‘Safety’ and ‘Quality’.
    Is it possible that when Safety is selected that the fontchanges to red and semi-bold?


    If it is possible how do I go about doing it? I must addthat my knowledge of VBA is very limited although I am learning as I go aboutbuilding DB’s.
    Many thanks

  2. #2
    Minty is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,002
    In the after update event of your combo box use something like

    Code:
    Me.YourComboControlName.FontBold = False
    Me.YourComboControlName.ForeColor = VbBlack
    
    If Me.YourComboControlName = "Safety" Then
         Me.YourComboControlName.FontBold = True
         Me.YourComboControlName.ForeColor = VbRed
    End If
    Substitute YourComboControlName for the name of your combo control.

    If you can scroll through different records on your form then you would need to add the same code to the OnCurrent Event to update the combo based on the current records state.
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  3. #3
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,892
    Consider using Conditional Formatting instead of VBA.

    VBA code will set ALL instances of the control to the same format. Therefore VBA is not practical for Continuous or Datasheet form. Whereas CF will work regardless of form style.

    You will find CF on the ribbon Format tab.
    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.

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,892
    Won't be able to change font with Conditional Formatting but can change color and other effects (bold, underscore, italic).
    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.

  5. #5
    mick3911 is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Feb 2013
    Location
    Wirral, UK
    Posts
    66
    Hi Guys,

    Apologies for not thanking you both for your replies sooner, first chance I have had to get back to building the DB.

    Can't seem to get the VBA solution to work so went to try the CF solution but how do I write the expression?

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,892
    If combobox is bound to a field then just reference field.

    Expression is: [fieldname]="Safety"

    Or reference combobox name.

    Expression is: [comboboxname]="Safety"
    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.

  7. #7
    mick3911 is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Feb 2013
    Location
    Wirral, UK
    Posts
    66
    Not working for some reason and can't discover why.

  8. #8
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,892
    Works for me. So you will have to give more info or even provide db for analysis.
    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.

  9. #9
    mick3911 is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Feb 2013
    Location
    Wirral, UK
    Posts
    66
    Hi, apologies for the late reply. First chance I have had to work on the DB.

    Anyway, sorted the CF problem by deleting the data (which was only test data).

    Thanks for all your help.

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

Similar Threads

  1. VBA to change font color
    By data808 in forum Access
    Replies: 5
    Last Post: 10-23-2014, 11:10 AM
  2. Replies: 4
    Last Post: 08-03-2014, 10:10 PM
  3. Change font color in Query
    By Brian62 in forum Queries
    Replies: 2
    Last Post: 01-10-2013, 09:14 PM
  4. Change as per condition font color
    By miziri in forum Programming
    Replies: 1
    Last Post: 08-20-2009, 04:23 AM
  5. Color/font change in subform
    By AndyKim in forum Forms
    Replies: 9
    Last Post: 06-24-2009, 04:34 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