Results 1 to 6 of 6
  1. #1
    valdg_ is offline Novice
    Windows 8 Access 2013 64bit
    Join Date
    Mar 2018
    Posts
    6

    How to use VBA code to get colors in my report ?

    Hi everyone, this is my first post here and english is not my first language, I will try to ask my question as clear as I can.

    I've never used VBA code before (well only to draw a rectangle..). Now I'm trying to change backround color for one of my controls, in a report. I want the background to be yellow when the value inside is "Nouvelle piste d'action".
    Now I don't know if it matters here but I'm working on linked Excel tables.

    I did explore the BackColor code but I don't get how to call for my control the correct way.... or maybe there's other errors I don't see yet.

    Actually my code is like this:

    If (Me!acteur__2018_23_statut Like "Nouvelle piste d'action") Then
    Me!acteur__2018_23_statut.BackColor = JAUNE


    End If

    And ACCESS tells me that he doesn't find the field wich i'm referring. Here acteur_2018_23_statut is the name of my field. I don't know if the name I'm using is the good one... is there a way to know for sure ?

    Thanks a lot for those who will take some time trying to understand and answer my question !

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    The simplest solution is Conditional Formatting, on the ribbon. Your code would need to use a valid color constant, and would also need an Else for values that don't meet the test.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    valdg_ is offline Novice
    Windows 8 Access 2013 64bit
    Join Date
    Mar 2018
    Posts
    6
    ahhh c'était trop simple !
    Merci !! La mise en forme conditionnelle fonctionne très bien !

  4. #4
    valdg_ is offline Novice
    Windows 8 Access 2013 64bit
    Join Date
    Mar 2018
    Posts
    6
    Oups sorry I answered in french ahah,

    I said " ahhhh it was so easy all this time ! Conditional formating is working just fine !"

    Now... i don't get how to set this question as resolved...

  5. #5
    valdg_ is offline Novice
    Windows 8 Access 2013 64bit
    Join Date
    Mar 2018
    Posts
    6
    found it ! Thank you again for your time.

  6. #6
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    Happy to help! If my daughter was around, I could answer in French.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Set TAB Control colors
    By trevor40 in forum Forms
    Replies: 4
    Last Post: 07-25-2016, 01:25 AM
  2. Replies: 3
    Last Post: 04-25-2015, 07:41 AM
  3. Alternating colors in a report
    By 97rstd in forum Reports
    Replies: 6
    Last Post: 07-29-2014, 02:14 AM
  4. Botton Colors
    By tcheck in forum Access
    Replies: 1
    Last Post: 05-22-2013, 07:50 AM
  5. Replies: 30
    Last Post: 03-01-2011, 10:05 AM

Tags for this Thread

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