If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
How do I: trigger afterupdate event on a different form
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 |
#2
|
|||
|
|||
How do I: trigger afterupdate event on a different form
On Thu, 23 Oct 2008 16:51:24 -0700 (PDT), AC
wrote: 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 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 |
#3
|
|||
|
|||
How do I: trigger afterupdate event on a different form
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. "AC" wrote in message ... 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 |
Thread Tools | |
Display Modes | |
|
|