Invoking combobox change event

  • Thread starter Thread starter Steve Marshall
  • Start date Start date
S

Steve Marshall

Hi all,

I have a combo box with several combo boxes where changes in each must
cascade down and change the rowsource of the next. That's all OK within
that form, but the problem is that I cannot find a way to invoke either the
Change or Afterupdate events when the selection in a combo is changed by
code on another form, rather than by the user. I really need to be able to
do this. I have tried directly calling the AfterUpdate event procedure on
the combo from the other form (after making AfterUpdate Public), but this
causes compile errors. There has to be a way to make this happen, doesn't
there? All I want is for the Change or AfterUpdate event to fire when I
change the combo in code. Seems to me it should happen all by itself.

Thanks
 
Steve

You have a couple of probs:

Changing RowSource won't cause a Change or AfterUpdate to occur, only a
change of Value does that

Changing the Value in VB code won't trigger the events either (user
documentation and help are quite explicit on that)

To alter the RowSource property, you have to invoke the Requery method of
the combo, in code:
MyCombo.Requery

Create a public procedure within the target form that calls the requery for
the combo/s as described above and then call that from the other form or code
module, that should work.

Keith
 
Thanks Keith, but I haven't been as clear as I should have...

I know about Requery and changing the Rowsource - I AM changing the Value of
the combo box from the code in the other form. The problem is that doing
that doesn't fire the Change or AfterUpdate events. I actually thought I
had done this in a previous version of Access (simply by changing the
procedures to Public) and it had worked, but maybe not.

What I want is to be able to poke a value into one of these combos from code
on another form, and have the events cascade down the chain exactly as if
the user had changed one of the combos on the form where they live. It
seems odd to me that I can call the AfterUpdate event procedure from code on
the same form, but not from another form. Hmmm. Maybe I have to rethink
this!

Thanks for the reply anyway.
 
Steve said:
The problem is that doing
that doesn't fire the Change or AfterUpdate events. I actually thought I
had done this in a previous version of Access (simply by changing the
procedures to Public) and it had worked, but maybe not.

What I want is to be able to poke a value into one of these combos from code
on another form, and have the events cascade down the chain exactly as if
the user had changed one of the combos on the form where they live. It
seems odd to me that I can call the AfterUpdate event procedure from code on
the same form, but not from another form. Hmmm. Maybe I have to rethink
this!


Maybe the problem is how you're calling the AfterUpdate
procedure. Remember that a Public procedure in a form's
module is a method of the class and, outside the class
module, would be referenced using this kind of syntax:
Form!formname.procedurename
 
Back
Top