By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,827 Members | 2,220 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,827 IT Pros & Developers. It's quick & easy.

How to set background color in pushed button of Option Group.

P: n/a
I use a sewt of buttons, created from the "Option Group". I would like
to have the pushed button appearing in another color, so it is more
clearier which button is pushed. How to proceed it? I am an amateur in
VB.

Bart

Nov 13 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Hi Bart,

I dont know if you can set the colour of the buttons, but you CAN set
the colour of the Text on the buttons.

Assuming you have two buttons in your option group, do this:

In design mode, set the colour of the ForeColor of the button to red

Then in the AfterUpdate() of your option group, add the following code:

Private Sub fraMine_AfterUpdate()

If Me.fraMine.Value = 1 Then
Me.btnOne.ForeColor = 255 'red
Me.btnTwo.ForeColor = 0 'black
Else
Me.btnOne.ForeColor = 0 'black
Me.btnTwo.ForeColor = 255 'red
End If

End Sub
-----------------

Now the text colour on the buttons will toggle as you move between the
two.

HTH

Jean

Nov 13 '05 #2

P: n/a
Jean,

Thanks for your input. It works wihtin the record.
However, when I move to the next record, the color is not accoridng to
the value of the button, pressed when passing that record. So, only the
color does not change then, but the buttonvalue (pushed or not) does.
How to solve it?

Bart

Nov 13 '05 #3

P: n/a
"AA Arens" <ba***********@gmail.com> wrote
Thanks for your input. It works wihtin
the record.
If it is in the AfterUpdate event, you can only expect the code to execute
when you take action on the OptionGroup.
However, when I move to the next
record, the color is not accoridng to
the value of the button, pressed when
passing that record. So, only the
color does not change then, but the
buttonvalue (pushed or not) does.
How to solve it?


Include similar code in the OnCurrent event (which fires when a new record
becomes the current one), assuming the Option Group is bound to a Field in
the RecordSource, so would actually have a setting.

Larry Linson
Microsoft Access MVP
Larry Linson
Microsoft Access MVP
Nov 13 '05 #4

P: n/a
I use more than two options, actually 7, resulting in a long VB script
(though it is working):
Can I make this script shorter? Like in the first two sections for the
Toggle 90 - 95, and for 89 + 91 - 95:

Private Sub Frame86_AfterUpdate()
If Me.Frame86.Value = 1 Then
Me.Toggle89.ForeColor = 255 'red
Me.Toggle89.FontWeight = 700 'bold
Me.Toggle90.ForeColor = 0 'black
Me.Toggle90.FontWeight = 400 'normal
Me.Toggle91.ForeColor = 0 'black
Me.Toggle91.FontWeight = 400 'normal
Me.Toggle92.ForeColor = 0 'black
Me.Toggle92.FontWeight = 400 'normal
Me.Toggle93.ForeColor = 0 'black
Me.Toggle93.FontWeight = 400 'normal
Me.Toggle94.ForeColor = 0 'black
Me.Toggle94.FontWeight = 400 'normal
Me.Toggle95.ForeColor = 0 'black
Me.Toggle95.FontWeight = 400 'normal
End If
If Me.Frame86.Value = 2 Then
Me.Toggle90.ForeColor = 255 'red
Me.Toggle90.FontWeight = 700 'bold
Me.Toggle89.ForeColor = 0 'black
Me.Toggle89.FontWeight = 400 'normal
Me.Toggle91.ForeColor = 0 'black
Me.Toggle91.FontWeight = 400 'normal
Me.Toggle92.ForeColor = 0 'black
Me.Toggle92.FontWeight = 400 'normal
Me.Toggle93.ForeColor = 0 'black
Me.Toggle93.FontWeight = 400 'normal
Me.Toggle94.ForeColor = 0 'black
Me.Toggle94.FontWeight = 400 'normal
Me.Toggle95.ForeColor = 0 'black
Me.Toggle95.FontWeight = 400 'normal
End If

Etc..... (5 more sections follows)

Nov 13 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.