Results 1 to 4 of 4
  1. #1
    rmcgaffic is offline Novice
    Windows XP Access 2010 (version 14.0)
    Join Date
    Jun 2010
    Posts
    3

    Code or property to select MS Access color theme

    How can you programmatically select a specific color theme, either custom or MS Access standards such as Median, Paper, or Marquee?

    I have defined three custom color schemes using the path Design>Colors>Custom colors.

    My names and respective custom colors for Accent 1 and Accent 2 are as follows:



    BlackRed (Black, Red)
    BlackYellow (Black, Yellow)
    Custom1 (Green,Blue)

    I want to change the color of all the forms in my application to use the same color scheme without opening and changing each form.

    I already have code to successfully change the color, but it is driven by the Color Scheme selected when the form was FIRST created.

    If the form was originally created using scheme BlackRed, then I would like to specify the new color scheme as BlackYelllow, so that when my code to change color executes, Accent 2 will be changed from Red to Yellow.

    How would you use code to select color scheme Custom1(Green,Blue) from my list of three color schemes?

    I can successfully loop through forms and lighten or darken the color, but I can't figure out how to point the code to select a specific Color Theme whose Accent 2 color I wish to use.

    Here's what doesn't work,:

    With Forms(o.Name)
    .PaintPalette = "Custom1"
    .Detail.BackThemeColorIndex = 4
    .Detail.BackShade = 50
    End With


    Thanks,
    Bob

  2. #2
    Micron is online now Virtually Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,803
    Interesting, but beyond my version. If you're able to access the members of a custom group, wouldn't those members need either html or hex color values or vb constants (such as vbgreen) rather than just green. And wouldn't your reference have to be one less than the number of elements in the group? You have index = 4 but only have 2 elements in that group. However, I suspect that's not the case and what I'm reading is just an example. From what I've read, the defined palette is saved with the form when it's created. If you want to use a different palette, AFAIK, you have to modify it in code first. If this is just a user option thing and has nothing to do with having different palettes available for them to design, then why not include all the colors in one palette and use a function with select case block? Rather than altering code each time a user is added to the group (or changes their mind) have the options in a table of user preferences.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  3. #3
    rmcgaffic is offline Novice
    Windows XP Access 2010 (version 14.0)
    Join Date
    Jun 2010
    Posts
    3
    Thanks, Micron for the suggestion.

    I would like to be able to change a color scheme on a wholesale basis.

    I have a form with a single button which executes the following code:

    Private Sub Command0_Click()


    Dim o As Object

    Dim i As Integer


    For Each o In CurrentProject.AllForms
    If o.Name <> Me.Name Then
    DoCmd.OpenForm o.Name, acDesign, , , , acHidden
    With Forms(o.Name)
    .Detail.BackThemeColorIndex = 4
    .Detail.BackShade = 100
    End With
    DoCmd.Close acForm, o.Name, acSaveYes
    End If
    Next o


    End Sub

    The code works OK, for the forms that first created using the same Color Scheme. My problem is when a form was created with a different color scheme, in which case the code will not change the color. BackThemeColorIndex = 4 represents Accent 1. (0 to 3 are for text and background colors)

    If there were someway my code could reference what color scheme I wanted to apply, the problem would be solved.

    Bob McGaffic

  4. #4
    Micron is online now Virtually Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,803
    My problem is when a form was created with a different color scheme, in which case the code will not change the color.
    Yes, as I said
    From what I've read, the defined palette is saved with the form when it's created. If you want to use a different palette, AFAIK, you have to modify it in code first.
    I suppose that means you have to alter the values assigned to the palette; you can't swap the palette out. Can't be sure since I've never dabbled in this aspect. If you're saying your palette doesn't contain, say 4 colors that can be used for BackThemeColorIndex then I have no clue at all. Just basing these comments on what I read, which also indicated you can't even swap a palette after the form is created.

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

Similar Threads

  1. Replies: 2
    Last Post: 11-09-2016, 05:54 PM
  2. Alternate Back Color Property
    By RayMilhon in forum Reports
    Replies: 5
    Last Post: 11-15-2012, 06:20 PM
  3. Help with Code to set ChartTitle Property
    By Kirsti in forum Programming
    Replies: 5
    Last Post: 05-08-2012, 08:17 PM
  4. Using SELECT query within a VBA code in Access
    By championss in forum Programming
    Replies: 4
    Last Post: 10-23-2006, 05:50 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