Change background color of button

cpampas

Registered User.
Local time
Yesterday, 19:26
Joined
Jul 23, 2012
Messages
221
I am trying from a button in the main form to change the background color of another button in a continuous subform header section

Forms![frmConcilManual]![frmSBancoNCont_P].Form![Command58].BackColor = RGB(255, 242, 0)
[frmSBancoNCont_P].Form.Repaint

frmSBancoNCont_P is the name of the control and form name aswell

i can change the color if the target button is in main form , but not if it is in the subform.
Any ideas ? thanks
 
It is possible that you are getting caught on a subtlety of forms. If, as you describe, the button in question is in the header of a form for which the details are in continuous mode, you need to tell Access that the control you wanted is in the header section.


You might need to reference something like this:

Code:
Forms![frmConcilManual]![frmSBancoNCont_P].Form.Section(acHeader)![Command58].BackColor = RGB(255, 242, 0)

Or, since sometimes the symbolic section names aren't defined, and since acHeader = 1, just use ...Form..Section(1)!...
 
Thanks for your reply. I get an error : Run-Time error '438' Object doesn't support this property or method
I am going to create a new form from scratch, and test it.
Shouldnt I set the focus to the subform before i change the back color of the button ?
 
Subform does not require focus. Must use subform container control name. Since container has same name as subform, your code should work. Does for me. I always name container different from the object it holds, like ctrBanc. The Repaint is not necessary.

And no, don't need to reference section.

Since code is behind main form, could use Me.

Me.ctrBanc.Form.Command58.Backcolor = RGB(255, 242, 0)
 
I did as June7 suggested, changed the name of the control to ctrSBancoNCont_P, so that it is different from the actual form name

Me.ctrSBancoNCont_P.Form.Command58.BackColor = RGB(255, 242, 0)

no errors, but still, no color was changed.
the path to the button is now correct since Me.ctrSBancoNCont_P.Form.Command58.caption="XX", results in changing the caption.
I wonder why the background color wont change
 
Do yourself a huge favour.
Give your controls meaningful names.
Command58 is not going to mean anything to you a few days down the road. Nor to any poor sod who has to take it over from you. :(
 
CJ_London,
Enabling the button does not work
Me.ctrSBancoNCont_P.Form.Command54.Enabled = True '
Me.ctrSBancoNCont_P.Form.Command54.BackColor = RGB(255, 242, 0)

Would you mind take a look, maybe it works with you. I attached a copy.
Thanks
 

Attachments

What version of Access are you using?
 
 
yes there is a property to change the back color
 

Attachments

  • prop.jpg
    prop.jpg
    59.5 KB · Views: 136
Gasman,
That worked great. Many thanks for your kind help
Cheers
 
Using Access 2010. I have never done anything with themes. I have no idea how to enable or disable themes. The "Quick Styles" icon is greyed out.
Code to set button backcolor works for me.
 

Users who are viewing this thread

Back
Top Bottom