Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Changing Background color After Update doesn't work 2

Status
Not open for further replies.

mraetrudeaujr

Technical User
Dec 20, 2004
137
US
I have been working with the "After Update" Event Procedure on a particular control. I've got it worked out to where my "IF" statements are doing what I need them to do, with one exception...the one where I want to BackGround to change color, doesn't. Here is my code:

Code:
Private Sub cboCountryPage2_AfterUpdate()
  
  If Me.cboCountryPage2.Column(3) = 1 Then
     Me.optgrpSIRCountryPage2.Value = 1
  Else
     Me.optgrpSIRCountryPage2.Value = 2
End If

  If Me.cboCountryPage2.Column(3) = 1 Then
     Me.optgrpSIRCountryPage2.BackColor = vbRed
  Else
     Me.optgrpSIRCountryPage2.BackColor = vbBlue
End If
  
  If Me.cboCountryPage2.Column(4) = 1 Then
     Me.optgrpOTMpage4.Value = 1
  Else
     Me.optgrpOTMpage4.Value = 2
End If

End Sub

As you can see, my first statement changes an option group's value based on what country is selected; the second, I want the BackGround color to change to RED based on the first statement (of course); and the last statment changes another option group value based on the country selection. What went wrong with my code? The first and last statements work as coded, but the second doesn't change the background color. I have tried both the number-codes for the colors and the VB coding (vbRed and VbBlue). The vbBlue is for testing purposes, but I would rather have it be the default 'grey' background color. I first need to iron out why my IF statement isn't working. Suggestions? Code?
 
If you're working with an option group (well, often most controls), the backstyle is set to Transparent (0), while you probably want Normal (1) for the colours to show ...

Either set it to normal in design view, or alter it in code

[tt]Me!optgrpSIRCountryPage2.BackColor = 1 ' Normal or 0 Transparent[/tt]

Roy-Vidar
 
Oh dear, typo again, sorry

[tt]Me!optgrpSIRCountryPage2.BackStyle = 1 ' Normal or 0 Transparent[/tt]

Roy-Vidar
 
RoyVidar,

Yeah, I already figured that out and set the BackStyle to 'Normal'. I thought I had it fixed, but this still didn't yield the results I wanted.

Do you have another way that I could make this happen on the 'After Update' event for this combobox?

Al
 
How are ya mraetrudeaujr . . .
Microsoft said:
[blue]To use the BackColor property, [purple]the BackStyle property[/purple], if available, [purple]must be set to Normal[/purple].[/blue]

You'll need to default the backcolor the same as the section the control is in . . .


Calvin.gif
See Ya! . . . . . .
 
AceMan,

I checked, double-checked, and triple-checked the "Back Style(s)" of both the combo box control and the option group control. All are set to 'Normal'. I even changed the "Back Color" to be the same (white) as the combo box. Still nothing triggering.

However, I can set the "After Update" event on the Option Group (optgrpSIRCountryPage2) itself, manually click in the option group box (in this case the value was already set by the After Update event for the combo box...so I would be actually 'changing' the value...again), and the Back Color will change ??? Why doesn't it want to change when put with the After Update event for the combo box?

The idea is to cause the Back Color of the option box to change to red. Any help will be greatly appreciated...thank you all.
 
mraetrudeaujr . . .

I've simulated this with no problem (using the option groups AfterUpdate event . . . of course). I'd have to say something isn't right . . .

As a test, in a new form, instantiate an option group and see if you get the same results. If it fails, try the same in a new DB.

Let us know your findings . . . (it could very well be a matter of deleting & reinstantiating the control).

Calvin.gif
See Ya! . . . . . .
 
Okay, but which control? The combo box or the option group? If you would like, I have a 'sanitized' copy of my database without sensitive information. It is a zipped file, about 200Kb.
 
Okay, I'll try it first thing in the morning AceMan. Right now I'm soo tired. Thanks, and I'll get back to this thread tomorrow.

Al
 
Yup, second that.

This should work - there's probably something wrong somewhere, either something we're not seing, you're not doing, or something wrong with the db (corruption?).

Create a new db with a new form, create one option group (call it fraTest) and one combo (call it cboTest).

Behind a button try:

[tt]if me!fraTest.backstyle = 0 then
me!fraTest.backstyle = 1
me!fraTest.backcolor = vbred
me!cboTest.backstyle = 1
me!cboTest.backcolor = vbgreen
else
me!fraTest.backstyle = 0
me!cboTest.backstyle = 0
end if[/tt]

This should toggle the backcolor of the combo and the option group throught altering the backstyle.

Roy-Vidar
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top