Results 1 to 5 of 5
  1. #1
    CodeLiftSleep is offline Advanced Beginner
    Windows 10 Access 2013 32bit
    Join Date
    May 2017
    Posts
    48

    Question Conditional Toggle Button caption/forecolor/hovercolor issues on continuous report


    I'm using Access 2013 to create a report on a continuous form.

    I have gotten to a point where I can sort of get this to work by using the Details_Paint() event of the report, but there are some issues. The button captions correctly display "Active" or "Inactive" as the caption depending on the True/False property of the field, but...:
    The code is like so(i used random made up color codes, I don't have the exact ones in front of me to use):
    Code:
    Private Sub Details_Paint()
                   
                 if Me.IsActive then
                     IsActive.Caption = "Active"
                     IsActive.ForeColor = "18119899" <--should be a light yellow but is actually bright blue
                     IsActive.HoverColor = "59899999" <-- has no effect what so ever---this doesn't work
                     IsActive.PressedColor = "98989222" <--this is working properly
                     Me.Dirty = False <--not sure what this is supposed to do, saw it on a code example where the guy had this working to some degree but it seems to make no difference as I tried it with this as true, false and commented out--same results
                 else
                     IsActive.Caption = "Inactive"
                     IsActive.ForeColor = "18119899" <--this is working properly
                     IsActive.HoverColor = "59899999" <--this is working properly
                     IsActive.PressedColor = "98587772" <--this works properly initially if I step through it in VBA, but then as soon as the form shows it reverts to the "Use Theme" color(although the hover and fore colors still work properly)
                  End if

    1. The "Active" buttons won't display the correct "Fore color" and the "hover fore color" does not function. Basically the button stays the exact same no matter if you hover over it or not.
    2. The "Inactive" buttons change to the proper "Pressed Color" initially but then once it finishes, immediately change to the "Use Theme" color of red. The hover and fore colors still are set properly and work even after the color change.
    3. If I turn of "Use Theme" the buttons turn blocky and the colors seem to be set automatically by something I am not controlling because no matter what I set the colors as, it doesn't work---fore, hover and pressed colors don't work at all. The buttons also are pressed in for the active and "unpressed" for the inactive but like a block and no rounded edges or fancy shine to them like the Use Theme buttons have.


    So, I am at a loss now really---how can I make this work properly so that these toggle buttons will stay the proper colors?

    At this point I'd be happy if I could just get the Inactive buttons to stay the proper color, I don't even care that the fore and hover colors don't work on the Active buttons...

    Is the Details_Paint() Event the only way I can get the buttons to individually change in each row?

  2. #2
    davegri's Avatar
    davegri is online now Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,405
    Try it this way:
    Code:
    Form_FormFirst.IsActive.HoverColor = 59899999
    Replace FormFirst with your form name. Be sure to include the 'Form_' prefix.

    Well, I just re-read your post, and realize you're asking about a report. I've never used a command button on a report but this solution might work with prefix 'Report_' and the report name.

  3. #3
    Micron is offline Virtually Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,784
    Not really sure what you're trying to do as your terms are confusing. AFAIK:
    - a form cannot contain a report
    - the event you're using is specific to a form, not a report as you state.
    - those colour values are of Long data type although I believe Access will recognize &HBA1419 for example, but not if contained within quotes, which denote text values
    - a continuous form seldom/never works with this sort of manipulation as the controls are repeated as rows, hence the problem is properties propagate to all rows. Conditional formatting would probably provide greater success, but still requires some sort of hack.
    - not sure if you're referring to toggle or command buttons. Either way, older Access versions don't allow this, but again, there are hacks.

    .Dirty is a property of a form or report indicating whether or not the has changed but (at least in the case of forms) has not been saved. Up until now, I didn't realize it was a report property as well. Your best bet is probably to either
    - use conditional formatting for an unbound textbox that is positioned under the control(s) you want to colour, lock it, remove it from the tab order, remove its borders and set it to be flat. Then you can set its backcolor property according to the value of a field in the record.
    OR
    - if we're talking about a command button, try using images (coloured rectangles) and swapping them based on a record field value. Not sure conditional formatting is possible in this case, unless maybe it's done via vba.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  4. #4
    CodeLiftSleep is offline Advanced Beginner
    Windows 10 Access 2013 32bit
    Join Date
    May 2017
    Posts
    48
    Quote Originally Posted by Micron View Post
    Not really sure what you're trying to do as your terms are confusing. AFAIK:
    - a form cannot contain a report
    - the event you're using is specific to a form, not a report as you state.
    - those colour values are of Long data type although I believe Access will recognize &HBA1419 for example, but not if contained within quotes, which denote text values
    - a continuous form seldom/never works with this sort of manipulation as the controls are repeated as rows, hence the problem is properties propagate to all rows. Conditional formatting would probably provide greater success, but still requires some sort of hack.
    - not sure if you're referring to toggle or command buttons. Either way, older Access versions don't allow this, but again, there are hacks.

    .Dirty is a property of a form or report indicating whether or not the has changed but (at least in the case of forms) has not been saved. Up until now, I didn't realize it was a report property as well. Your best bet is probably to either
    - use conditional formatting for an unbound textbox that is positioned under the control(s) you want to colour, lock it, remove it from the tab order, remove its borders and set it to be flat. Then you can set its backcolor property according to the value of a field in the record.
    OR
    - if we're talking about a command button, try using images (coloured rectangles) and swapping them based on a record field value. Not sure conditional formatting is possible in this case, unless maybe it's done via vba.
    Sorry about the terminology...I am in fact using a report, and yes realize the issues with the single control...I find it weird that it is working in some cases, but not in others, for instance the Caption values are all set properly on the individual toggle buttons.
    It does not appear conditional formatting is possible with toggle buttons, but I think I can make it work with a text box and simply use conditional formatting based on the value of the IsActive field...I can get it to look sort of like a toggle button, but without the rounded edges--I know I can do it using the border-radius property in CSS but I don't think there is an equivalent I can use in Access as far as I know...

  5. #5
    Micron is offline Virtually Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,784
    Well, in my old version, there are no properties for back style, back colour or border style for toggle buttons. If that's still the case, it would appear that changing coloured images would be your easiest option if you want to maintain the slightly rounded corners. As I mentioned, there are hacks or sometimes 3rd party add-ins and the like. Stephen Lebans apparently has/had one here, which I have not reviewed (interesting read too)
    https://www.pcreview.co.uk/threads/c...color.1133450/

    You can also play with raised/sunken rectangles, although they do not have rounded corners either.

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

Similar Threads

  1. Toggle Button
    By gheyman in forum Access
    Replies: 2
    Last Post: 07-11-2017, 07:43 AM
  2. Replies: 3
    Last Post: 03-09-2016, 05:53 PM
  3. VBA caption button of record
    By Ruegen in forum Forms
    Replies: 4
    Last Post: 08-19-2013, 05:03 PM
  4. Toggle Button Help
    By dbalilti in forum Access
    Replies: 1
    Last Post: 07-05-2012, 04:23 AM
  5. Replies: 0
    Last Post: 01-12-2011, 12:43 PM

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