changing backcolor in combobox also chges color of list

G

Guest

i'm using a2k.

here's some vba i'm using to which i just added the annotated line


Private Sub cboStudy__AfterUpdate()
Me.cboReg1_.Enabled = True
Me.cboReg1_ = ""
Me.cboReg1_.BackColor = RGB(255, 0, 0) 'annotated line :)
Me.cboReg1_.Requery
Me.cboReg2_ = ""
Me.cboReg2_.Enabled = False
Me.[cboIRB#] = ""
Me.[cboIRB#].Requery
Me.cboReg1_.SetFocus
End Sub

the effect of changing the color in the control to red when the cursor moves
to cboreg1_ is to also change the color of the values in the lookup list the
user is going to choose from from black on white to black on red. i just want
the backcolor of the control to go red when the cursor moves there (and also
to display black on white) to remind the user to enter data.

is it not possible to manipulate things w/o mucking up the way the lookup
numbers are getting displayed?
 
D

Douglas J Steele

BackColor applies to the whole control.

You could try setting the ForeColor to vbWhite, so you'll get white text on
red (should be slightly more visible), or you could put code into the
control's GotFocus event to change it back from red once they select it.
 
G

Guest

well, i tried the first appraoch (setting forecolor to vbWhite) which
brightened things up a tad but when i went for the second effect
(me.cboReg1_.backcolor = vbWhite) into the GotFocus event that seemed to undo
the beneficial effect of the first one, meaning the control didn't even get
to turn red. perhaps you mean to put the me.cboReg1_.backcolor = vbWhite into
the control's AfterUpdate event?

-ted

Douglas J Steele said:
BackColor applies to the whole control.

You could try setting the ForeColor to vbWhite, so you'll get white text on
red (should be slightly more visible), or you could put code into the
control's GotFocus event to change it back from red once they select it.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Ted said:
i'm using a2k.

here's some vba i'm using to which i just added the annotated line


Private Sub cboStudy__AfterUpdate()
Me.cboReg1_.Enabled = True
Me.cboReg1_ = ""
Me.cboReg1_.BackColor = RGB(255, 0, 0) 'annotated line :)
Me.cboReg1_.Requery
Me.cboReg2_ = ""
Me.cboReg2_.Enabled = False
Me.[cboIRB#] = ""
Me.[cboIRB#].Requery
Me.cboReg1_.SetFocus
End Sub

the effect of changing the color in the control to red when the cursor moves
to cboreg1_ is to also change the color of the values in the lookup list the
user is going to choose from from black on white to black on red. i just want
the backcolor of the control to go red when the cursor moves there (and also
to display black on white) to remind the user to enter data.

is it not possible to manipulate things w/o mucking up the way the lookup
numbers are getting displayed?
 
D

Douglas J Steele

Your code is changing cboReg1's color so that people will notice it. I was
suggesting that once they've selected the control, you change it back from
red, assuming that they'd already noticed it. However, I missed the fact
that you're setting focus to cboReg1, in addition to changing its color.

Either don't set the focus for them, so that they need to select it
themselves, or consider doing something other than changing the BackColor
(such as setting the control's Label red, like is common on many web pages)

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Ted said:
well, i tried the first appraoch (setting forecolor to vbWhite) which
brightened things up a tad but when i went for the second effect
(me.cboReg1_.backcolor = vbWhite) into the GotFocus event that seemed to undo
the beneficial effect of the first one, meaning the control didn't even get
to turn red. perhaps you mean to put the me.cboReg1_.backcolor = vbWhite into
the control's AfterUpdate event?

-ted

Douglas J Steele said:
BackColor applies to the whole control.

You could try setting the ForeColor to vbWhite, so you'll get white text on
red (should be slightly more visible), or you could put code into the
control's GotFocus event to change it back from red once they select it.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Ted said:
i'm using a2k.

here's some vba i'm using to which i just added the annotated line


Private Sub cboStudy__AfterUpdate()
Me.cboReg1_.Enabled = True
Me.cboReg1_ = ""
Me.cboReg1_.BackColor = RGB(255, 0, 0) 'annotated line :)
Me.cboReg1_.Requery
Me.cboReg2_ = ""
Me.cboReg2_.Enabled = False
Me.[cboIRB#] = ""
Me.[cboIRB#].Requery
Me.cboReg1_.SetFocus
End Sub

the effect of changing the color in the control to red when the cursor moves
to cboreg1_ is to also change the color of the values in the lookup
list
the
user is going to choose from from black on white to black on red. i
just
want
the backcolor of the control to go red when the cursor moves there
(and
also
to display black on white) to remind the user to enter data.

is it not possible to manipulate things w/o mucking up the way the lookup
numbers are getting displayed?
 
G

Guest

hi doug (with your help), we've licked it this time: i set it to red back and
white fore colors when moving to the control and once it loses focus i
reverse/revert to the black on white. it seems to handle through the curves
alright.

thanks!

-ted

Douglas J Steele said:
Your code is changing cboReg1's color so that people will notice it. I was
suggesting that once they've selected the control, you change it back from
red, assuming that they'd already noticed it. However, I missed the fact
that you're setting focus to cboReg1, in addition to changing its color.

Either don't set the focus for them, so that they need to select it
themselves, or consider doing something other than changing the BackColor
(such as setting the control's Label red, like is common on many web pages)

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Ted said:
well, i tried the first appraoch (setting forecolor to vbWhite) which
brightened things up a tad but when i went for the second effect
(me.cboReg1_.backcolor = vbWhite) into the GotFocus event that seemed to undo
the beneficial effect of the first one, meaning the control didn't even get
to turn red. perhaps you mean to put the me.cboReg1_.backcolor = vbWhite into
the control's AfterUpdate event?

-ted

Douglas J Steele said:
BackColor applies to the whole control.

You could try setting the ForeColor to vbWhite, so you'll get white text on
red (should be slightly more visible), or you could put code into the
control's GotFocus event to change it back from red once they select it.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


i'm using a2k.

here's some vba i'm using to which i just added the annotated line


Private Sub cboStudy__AfterUpdate()
Me.cboReg1_.Enabled = True
Me.cboReg1_ = ""
Me.cboReg1_.BackColor = RGB(255, 0, 0) 'annotated line :)
Me.cboReg1_.Requery
Me.cboReg2_ = ""
Me.cboReg2_.Enabled = False
Me.[cboIRB#] = ""
Me.[cboIRB#].Requery
Me.cboReg1_.SetFocus
End Sub

the effect of changing the color in the control to red when the cursor
moves
to cboreg1_ is to also change the color of the values in the lookup list
the
user is going to choose from from black on white to black on red. i just
want
the backcolor of the control to go red when the cursor moves there (and
also
to display black on white) to remind the user to enter data.

is it not possible to manipulate things w/o mucking up the way the lookup
numbers are getting displayed?
 
M

Marshall Barton

Ted said:
i'm using a2k.

here's some vba i'm using to which i just added the annotated line


Private Sub cboStudy__AfterUpdate()
Me.cboReg1_.Enabled = True
Me.cboReg1_ = ""
Me.cboReg1_.BackColor = RGB(255, 0, 0) 'annotated line :)
Me.cboReg1_.Requery
Me.cboReg2_ = ""
Me.cboReg2_.Enabled = False
Me.[cboIRB#] = ""
Me.[cboIRB#].Requery
Me.cboReg1_.SetFocus
End Sub

the effect of changing the color in the control to red when the cursor moves
to cboreg1_ is to also change the color of the values in the lookup list the
user is going to choose from from black on white to black on red. i just want
the backcolor of the control to go red when the cursor moves there (and also
to display black on white) to remind the user to enter data.

is it not possible to manipulate things w/o mucking up the way the lookup
numbers are getting displayed?


I don't think so. The colors in the list are the same as
the colors of the combo box. What's more, the selection
colors are the "complement" of the colors, which can be
pretty ugly for some combinations of fore and back colors.

A different approach is to place a red rectangle control
behind the combo box. Make it a little bigger than the
combo box so it looks like a fat border all the way around,
Then use the GotFocus/LostFocus events to make it
visible/invisible.
 
G

Guest

i figured my 'newbie' elevation was between the behaviour i was getting and
the 'ideal' representation of those values on the form, but apparently it's
the way they cobbled A2k together. your idea is a nice one and i will
investigate and likely implement.

much obliged!

-ted

Marshall Barton said:
Ted said:
i'm using a2k.

here's some vba i'm using to which i just added the annotated line


Private Sub cboStudy__AfterUpdate()
Me.cboReg1_.Enabled = True
Me.cboReg1_ = ""
Me.cboReg1_.BackColor = RGB(255, 0, 0) 'annotated line :)
Me.cboReg1_.Requery
Me.cboReg2_ = ""
Me.cboReg2_.Enabled = False
Me.[cboIRB#] = ""
Me.[cboIRB#].Requery
Me.cboReg1_.SetFocus
End Sub

the effect of changing the color in the control to red when the cursor moves
to cboreg1_ is to also change the color of the values in the lookup list the
user is going to choose from from black on white to black on red. i just want
the backcolor of the control to go red when the cursor moves there (and also
to display black on white) to remind the user to enter data.

is it not possible to manipulate things w/o mucking up the way the lookup
numbers are getting displayed?


I don't think so. The colors in the list are the same as
the colors of the combo box. What's more, the selection
colors are the "complement" of the colors, which can be
pretty ugly for some combinations of fore and back colors.

A different approach is to place a red rectangle control
behind the combo box. Make it a little bigger than the
combo box so it looks like a fat border all the way around,
Then use the GotFocus/LostFocus events to make it
visible/invisible.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top