Option group color change (1 Viewer)

rmatkovic

New member
Local time
Today, 07:17
Joined
Jan 7, 2010
Messages
7
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
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 02:17
Joined
May 21, 2018
Messages
8,463
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.
 

CJ_London

Super Moderator
Staff member
Local time
Today, 06:17
Joined
Feb 19, 2013
Messages
16,553
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
 

moke123

AWF VIP
Local time
Today, 02:17
Joined
Jan 11, 2013
Messages
3,852
Something like this?
 

Attachments

  • New Microsoft Access Database.accdb
    568 KB · Views: 205

rmatkovic

New member
Local time
Today, 07:17
Joined
Jan 7, 2010
Messages
7
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 .
 

moke123

AWF VIP
Local time
Today, 02:17
Joined
Jan 11, 2013
Messages
3,852
"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)
 

rmatkovic

New member
Local time
Today, 07:17
Joined
Jan 7, 2010
Messages
7
"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

  • Database51.accdb
    396 KB · Views: 170

Uncle Gizmo

Nifty Access Guy
Staff member
Local time
Today, 06:17
Joined
Jul 9, 2003
Messages
16,245
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:-

 

Gasman

Enthusiastic Amateur
Local time
Today, 06:17
Joined
Sep 21, 2011
Messages
14,048
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. :)
 

moke123

AWF VIP
Local time
Today, 02:17
Joined
Jan 11, 2013
Messages
3,852
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
 

rmatkovic

New member
Local time
Today, 07:17
Joined
Jan 7, 2010
Messages
7
Thanks to All, Now it's working perfect. After I change from transparent to Normal.
 

Users who are viewing this thread

Top Bottom