Strange behaviour of AfterUpdate event 
Author Message
 Strange behaviour of AfterUpdate event

I have discovered some odd behaviour of the
AfterUpdate event for textboxes in VBA for
Word2000 (haven't tried it on Word97).  The
online help says that this event is invoked after
USER INPUT update of a field (i.e. not
programmatic change).  This is borne out by
numerous examples in my experience, EXCEPT in the
following case.

Create a form (frmTest) that contains 3
textboxes, txtA, txtB and txtC and one command
button btnCancel.  Tab order: A, B, C, button.
Add the following code to the form:

Private Sub btnCancel_Click()
    Unload frmTestUpdate
End Sub

Private Sub txtA_AfterUpdate()
    txtC.Value = txtA.Value & " " & txtB.Value
End Sub

Private Sub txtB_AfterUpdate()
    txtC.Value = txtA.Value & " " & txtB.Value
End Sub

Private Sub txtC_AfterUpdate()
    txtA.Value = "txtC_AfterUpdate invoked"
    txtB.Value = txtC.Value
End Sub

Create a macro with the line:
   frmTest.show

and run the macro.

In doing this, I find that changing A and tabbing
to B does NOT invoke the AfterUpdate event on C
(as I would expect).  However, changing B and
tabbling to C invokes the AfterUpdate event on B
(as expected) and then on C (should not
happen!).  Try it.

You can see what's happening if you breakpoint on
each event.  However, if you step through the
code (fn key F8), the form behaves as you would
expect - even more strange!

Any suggestions, anyone?  Genuine bug?  My
misunderstanding of something?

Sent via Deja.com http://www.*-*-*.com/
Before you buy.



Sun, 05 Jan 2003 03:00:00 GMT  
 Strange behaviour of AfterUpdate event

Quote:
> In doing this, I find that changing A and tabbing
> to B does NOT invoke the AfterUpdate event on C
> (as I would expect).  However, changing B and
> tabbling to C invokes the AfterUpdate event on B
> (as expected) and then on C (should not
> happen!).  Try it.

I confirm what you see (also Word 2000). Can't explain it, though;
nothing in the KB.

Adding an additional text box and adjusting the tab order: the problem
is maintained - the next to last text box in the tab order causing
AfterUpdate to execute on the last text box.

Putting the command button before the last text box in the tab order -
the problem does not occur.

I'd say this is a bug.

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister
http://go.compuserve.com/MSOfficeForum

This reply is posted in the Newsgroup; please post any follow question
or reply in the newsgroup and not by e-mail :-)



Fri, 10 Jan 2003 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Strange control event behaviour

2. Strange control event behaviour

3. Strange behaviour in the KeyDown event

4. AfterUpdate Event Select Query

5. Setting Focus In AfterUpdate Event

6. AfterUpdate (event) for a form

7. BeforeUpdate/AfterUpdate event when form control is empty

8. MultiSelect Listbox AfterUpdate Event?

9. DataGrid AfterUpdate event problem with vb6

10. AfterUpdate Event?

11. Set focus within AfterUpdate event for textbox

12. AfterUpdate Event Problems

 

 
Powered by phpBB® Forum Software