Results 1 to 5 of 5
  1. #1
    ThomasAJ is offline Novice
    Windows 10 Access 2016
    Join Date
    Oct 2020
    Posts
    1

    I cannot set a Command Button "Quick Style" in VBA unless a "Quick Style" has already been set.


    Access 2016

    I wish to convert 100s of buttons from the classic 3D style of Access 2003 to something more modern upon loading a form - using a Quick Style.

    What is happening is that 'ctl.QuickStyle = 2' is being totally ignored in the code below unless the control has already had a quick style (say 3) applied manually in form design mode.

    See Microsoft link for Quick Style numbers.

    Code:
    Private Sub Form_Load()
    
    
        ' https://docs.microsoft.com/en-us/office/vba/api/access.commandbutton.quickstyle
        
        Dim ctl As Control
        
        For Each ctl In Me.Controls
        
            If ctl.ControlType = acCommandButton Then
                If ctl.Name = "cmdTarget1" Then
                    ctl.QuickStyle = 2
                End If
            End If
        
        Next ctl
    
    
    End Sub
    I couldn't find anything about this possible issue Googling.

  2. #2
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,977
    From your description...just a guess as I've not tested it myself...
    Perhaps you need to loop through all the forms and add a quick style property to each?

    Or a manual approach that may be faster...
    Modify the buttons on one of your forms. Then select a button & click Format Painter.
    Then go to each form in turn and click the buttons to 'paint' the new format.

    Many years ago in the past, I did it all manually...
    I imported a 'template button in the new format to each form, used format painter as above then cut the template button to the next form.
    And I had hundreds of forms!
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  3. #3
    davegri's Avatar
    davegri is offline Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,413
    As Colin says:
    Modify the buttons on one of your forms. Then select a button & click Format Painter.
    Then go to each form in turn and click the buttons to 'paint' the new format.
    If you double click on Format Painter it will stay selected and allow you to paint a series of buttons. It will stay selected until you click it again.

  4. #4
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,801
    Interesting, so I play. A test form is open in form view and in immediate window
    ?forms!form1.command2.quickstyle and the result is
    0
    which means no quick style, yes?

    forms!form1.command2.quickstyle = 3 and it turns white (background color) with an orange border

    Perhaps your issue is something else, such as the tag or the wrong event. According to the documentation the property is just there - you don't have to create it.
    Why do this in the load event? You can't save design changes that are done in form view even if you get that code to work.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  5. #5
    Join Date
    Aug 2023
    Posts
    1

    Thumbs up

    You have to first enable theme then only it is accept quickstyle code.
    Code:
            
               CommandButton.UseTheme = vbYes
               CommandButton.QuickStyle = 23
    for more quick style you can refer this thread CommandButton.QuickStyle property (Access) | Microsoft Learn

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

Similar Threads

  1. Replies: 1
    Last Post: 11-27-2016, 05:22 PM
  2. Replies: 1
    Last Post: 11-17-2016, 10:55 AM
  3. Replies: 1
    Last Post: 09-03-2014, 03:27 AM
  4. Replies: 30
    Last Post: 09-27-2013, 01:34 PM
  5. Complex "sumif" style formula
    By groonpooch in forum Queries
    Replies: 3
    Last Post: 12-16-2011, 07:05 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