Option group color change

rmatkovic

New member
Local time
Tomorrow, 00:38
Joined
Jan 7, 2010
Messages
8
Hello Access Masters,

I'm new in AccessWorld (not quietly new in access, but on this form :))
I have one little problem
Below is picture of my group with 3 options buttons. Those group I have on one access Form. I need code which can paint all group based on selected option.
For example Open = Red, InWork = Yellow, Close = Green

OptionButtonFormating.jpg

I tried several options, but I'm not happy with solution, Currently I have code
Code:
Private Sub frmOrderStatus_Exit(Cancel As Integer)
With Me.frmOrderStatus
.BackStyle = 1
.BackColor = vbWhite
If .Value = 1 Then
.BackColor = vbRed
ElseIf .Value = 2 Then
.BackColor = vbYellow
ElseIf .Value = 3 Then
.BackColor = vbGreen
End If
End With
End Sub

But, I want to change color immediately after I click on next field on form, not only when I leave form. And when I listing records true form I want to see those colors. Currently those three colors not shown until I click into records on form


Thanks
 
I do not really understand how you are set up. Do you change the recordsource of the displayed records too?
You may want to look at conditional formatting.
However, the code is in the frames exit event seems it should at least be in the on change event.
 
I presume frmOrderStatus the name of your option group?

and I presume 'not only when I leave form.' means control not form

perhaps use the option button mouse up event?

e.g. for option 1
frmOrderStatus.BackColor = vbRed

@MajP - frames don't have a change event
 
Hi, moke123, I tried your suggestion in my database environment, not work. I tried to create exactly like is your database (copy, paste everything) not works.
I don't understand why in yours database works, but in my not!?, Could be a problem of Access version? I'm using, Microsoft® Access® for Microsoft 365 MSO (Version 2204 Build 16.0.15128.20240) 64-bit .
 
"Not work" doesn't really explain the problem.
(copy, paste everything)
Did you change the object names in the code to your object names? (ie. Frame0)
 
"Not work" doesn't really explain the problem.

Did you change the object names in the code to your object names? (ie. Frame0)
yes, of course. In attachment is my database , created like is your, step-by-step. I cant see any differences, Please take a look, if you can find some mistake
 

Attachments

It appears that you have something working, so my observation might be irrelevant.

I have noticed a problem in the past in setting the option group label colours, in that the default is for the the label to be set to transparent. This means when you try and change the label colour, it does change, but you cannot see the change...

More about that on my blog here:-

 
It appears that you have something working, so my observation might be irrelevant.

I have noticed a problem in the past in setting the option group label colours, in that the default is for the the label to be set to transparent. This means when you try and change the label colour, it does change, but you cannot see the change...

More about that on my blog here:-

Nice one Tony. You appear to have hit the nail on the head. :)
 
your back style was set to transparent. Change it to normal.
Bind the frame to your field
Make sure the property sheet shows [Event Prodedure] in the events
 
Thanks to All, Now it's working perfect. After I change from transparent to Normal.
 

Users who are viewing this thread

Back
Top Bottom