Can't change property of subform control selectively

  • Thread starter mav51 via AccessMonster.com
  • Start date
M

mav51 via AccessMonster.com

Hi all,
I would like to change the forecolor of a combobox depending on which option
is selected. The combobox is populated by a lookup table with an inidex
field.
ie. option 0 = closed - combobox.forecolor = 0
option 1 = open - combobox.forecolor = 255
I can change the color of all the rows but I can't seem to figure out how to
make it change selectively. If it makes a difference, the form is based on a
query.

Thanks in advance
Mike
 
M

mav51 via AccessMonster.com

I should also mention that the combobox control is in a subform.
 
L

Linq Adams via AccessMonster.com

It would help if we could see what code you've already tried.
 
M

mav51 via AccessMonster.com

I haven't tried anything really fancy. If I try 'me.subform.form.txtstatus.
forecolor = 255' then the text changes color but for all records. Then I
tried 'If me.subform.form.txtstatus.value = 6 then me.subform.form.txtstatus.
forecolor = 255'
Again, all records change color, not just the records where the recordsource
for txtstatus is '6'.
 
M

Marshall Barton

mav51 said:
I haven't tried anything really fancy. If I try 'me.subform.form.txtstatus.
forecolor = 255' then the text changes color but for all records. Then I
tried 'If me.subform.form.txtstatus.value = 6 then me.subform.form.txtstatus.
forecolor = 255'


I think you might have left out a critical bit of
information. If the sub form is displayed in continuous or
datasheet view, there is no way to do that using code.

Instead, you should use Conditional Formatting on the Format
menu.
 
L

Linq Adams via AccessMonster.com

And if the combobox is not bound to a field in the underlying query,
Conditional Formatting won't work, either. When the combobox is selected and
you go to Properties - Data, is there a field name in the Control Source
property box?
 
M

mav51 via AccessMonster.com

Yes, the subform is displayed in continuous format, but the combobox is bound
to a field. The conditional formating option works perfectly.

Thanks, I didn't even know that option was there!
Michael
 

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