Updating the row source of a combo

  • Thread starter Thread starter aine_canby
  • Start date Start date
A

aine_canby

Hello,

I have a form which contains a comboBox representative of one of my
fields. The options available in this comboBox are dependant on the
other feilds for the current row. Therefore I use Form_Current to
update the row source for the combo. The problem is that this update
seems to happen too late. As a result, I sometimes have nothing in my
comboBox's text box, even when I know a value should exist there. If I
click in the combo's text box the correct value will then appear. How
might I solve this problem.

Thanks,
Aine.
 
Hello,

I have a form which contains a comboBox representative of one of my
fields. The options available in this comboBox are dependant on the
other feilds for the current row. Therefore I use Form_Current to
update the row source for the combo. The problem is that this update
seems to happen too late. As a result, I sometimes have nothing in my
comboBox's text box, even when I know a value should exist there. If I
click in the combo's text box the correct value will then appear. How
might I solve this problem.

Have you tried moving the rowsource update to the beginning of the Current event procedure? Or perhaps requerying the
combo after setting the rowsource:

Me.YourCombo.Requery

Setting the RowSource should automatically force the combo to requery, but explicitly calling the Requery method may
work in this case.

Alternatively: you could use the form's Timer event to perform the requery. To me, that's a kludge but if it works ...

Scott McDaniel
scott@takemeout_infotrakker.com
www.infotrakker.com
 
I think Scott's advice is right on! You definitely need to requery your
combobox if you're going to give it a new RowSource with each record. As it
is, the requerying is only coming about after it has gained focus (by you
clicking on it.)

--
There's ALWAYS more than one way to skin a cat!

Answers/posts based on Access 2000

Message posted via AccessMonster.com
 
Have you tried moving the rowsource update to the beginning of the Current event procedure? Or perhaps requerying the
combo after setting the rowsource:

Me.YourCombo.Requery

Setting the RowSource should automatically force the combo to requery, but explicitly calling the Requery method may
work in this case.

Alternatively: you could use the form's Timer event to perform the requery. To me, that's a kludge but if it works ...

Scott McDaniel
scott@takemeout_infotrakker.comwww.infotrakker.com

Me.YourCombo.Requery worked, thanks. Although I was looking forward to
trying the timer option ;)
 
Aine,
Since the RowSource of your combo depends on the value of several fields, I would think
you'd need to "re-examine" the combo rowsource upon the change in the value of any of
those "other" fields (ex. those field's AfterUpdate events).
You don't indicate whether you ALWAYS have those other field values entered, and
evaluated, before the combo rowsource is established and a combo selection is made.
If not... then you'll have to code to evaluate the other fields, and make a decision
what rowsource the combo will have, on the OnEnter event or Click event of the combobox...
as a final check in preperation for selecting a combo value.

--
hth
Al Campagna . Candia Computer Consulting . Candia, NH USA
Microsoft Access MVP
http://home.comcast.net/~cccsolutions

"Find a job that you love, and you'll never work a day in your life."
 
Back
Top