Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Afterupdate property and On got focus property--order?

Status
Not open for further replies.

jgarnick

Programmer
Feb 16, 2000
189
US
I have an event procedure that is run by the Afterupdate property for a control. This procedure captures some variables and drops them in a table.<br>
<br>
I also have a macro that is run by the On Got Focus property for the same control (above) that indents and changes the color of the activecontrol.<br>
<br>
Right now the macro fails if you update this control, it does not fail otherwise. So the Afterupdate property event procedure is causing the macro to fail--I'm not sure why?? What happens to the focus when an event procedure is run?<br>
<br>
Any ideas?
 
Not sure exactly what's going on.<br>
But did you know that the After update event is only tripped if the item has changed i.e. &quot;after update&quot;.<br>
If you just click in the box and leave it your are not tripping the after update event. Make one slight change to the item and you will trip the event...<br>
<p> DougP<br><a href=mailto: dposton@universal1.com> dposton@universal1.com</a><br><a href= > </a><br>
 
Thanks DougP--I know that the Afterupdate event does not run unless you update the field--see my last paragraph--that's why I know the running of this event causes the macro to fail--I was just wondering why the event would cause the macro to fail........actually my question is what happens first--the focus is lost or the event property is run due to the update?? <p>jgarnick<br><a href=mailto:jgarnick@aol.com>jgarnick@aol.com</a><br><a href= > </a><br>
 
Now I'm not sure waht your question is. When you say fail.<br>
Is there an Error or is Access just not processing your code the way you want.<br>
<br>
One way to find out which order events are tripped is make a test form with just one text box on it.<br>
Put some code in each event of that text box.<br>
Like <br>
Debug.print &quot;Tripped in After Update Event&quot; <br>
in the after update event and then &quot;Tripped On Exit&quot; in the &quot;On Exi&quot;t event and so on.<br>
then Press Ctrl-G to bring up the debug window, while in code view. View the form and click in the text box type in some text leave the textbox and see which order your debug prints are in.<br>
<br>
<p> DougP<br><a href=mailto: dposton@universal1.com> dposton@universal1.com</a><br><a href= > </a><br>
 
Thanks again DougP. When I say the macro fails, I get a box that pops up and the heading says Action Failed and it lists the macro command and then the only button you can press is Halt. After pressing Halt, the action is not done and it just drops me into the form.<br>
<br>
I will try what you suggested to see what happens first. I guess I still don't know why one event procedure would affect the other regardless of the order. That's my question! <p>jgarnick<br><a href=mailto:jgarnick@aol.com>jgarnick@aol.com</a><br><a href= > </a><br>
 
The OnGotFocus event happens first. However if your OnGotFocus event is changing your control, then it is triggering your AfterUpdate event. If your AfterUpdate event used the control's .SetFocus method, then it would trigger the OnGotFocus event again, in a circular reference.
 
&lt;&lt;...triggering the AfterUpdate. &gt;&gt;<br>
That depends. Only if you explicitly set the .text property of the control. Just saying:<br>
me!mycontrol = &quot;somevalue&quot;<br>
won't trigger AfterUpdate.<br>
Neither will setting the underlying field, which gets more confusing when the control and field are named the same (for this, amongst other reasons, I never name them the same--and when the wizard creates them I change the control name, prefixing with txt, cbo, etc).<br>
--Jim
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top