How do I: trigger afterupdate event on a different form

A

AC

Hi

I would like to run some code in a module (or perhaps another form)
which:

1. opens another form
2. populates a combo box with a particular value that I want
3. runs the after update event for that combo box.

I have the following code which does steps 1 and 2 OK:

stFormName = "f_combo"
DoCmd.OpenForm stFormName, , , stLinkCriteria
Forms(stDocName).Controls("Combo3").Value = "Hello"

I need to know how to do step (3)

Out of interest, what triggers an after update event? I naively
expected my code above to trigger it automatically when I updated the
value to "hello".

When you answer, could you also indicate if I need to make my after
update event on Combo3 public, or can it remain "private" and still
work.

Thanks in advance
Andy C
 
T

Tom van Stiphout

On Thu, 23 Oct 2008 16:51:24 -0700 (PDT), AC

Change that procedure to Public.
Or put most of the code in a Public procedure in a standard module,
and call it from both the AfterUpdate event, and your current code.

-Tom.
Microsoft Access MVP
 
K

Klatuu

Tom's solution is correct. I would recommend the actual code be in a public
sub or function in a standard module so that it can be called from both the
combo's After Update and from your code.

As to why it does not fire from your code. After Update and some other
events - Before Update, for example, only fire when the control is updated
manually. Changing the value of the control using VBA or a Macro will not
cause the events to fire. This is not a shortcoming, but a advantage. It
gives you more control. You really don't want events firing when you make
changes in code.
 

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