View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Linc Linc is offline
external usenet poster
 
Posts: 8
Default Button clicks and textbox Exit events

I wrote:

"I'll call a sub to write data to the datasheet from the buttons' Click
event handlers and write handlers for the textboxes' Enter events to do
the same thing. The Exit event handlers will simply send up a "Changed
Data" flag for the other handlers to deal with. Here's hoping it
works."

It involves quite a bit more code in comparison to my original, but it
does indeed work. And it's even a bit faster for some reason.

Apparently, when VBA encountered this line in a textbox's Exit event
handler...

Cells(R, [FirstName].Column).Value = FieldEntry(1)

....and the Exit event was triggered by clicking on a button, VBA
updated the cell and then promptly forgot where the focus was supposed
to have gotten to. Therefore, it didn't run the button's Click
handler. By using the button's Click event handler to call a Sub that
in turn writes the data using Cells(), VBA is able to write the data
and continue with the handler. The focus doesn't get "lost" because
VBA doesn't deal with any other control.

I still wish I knew if the original code was encountering a bug in
Excel VBA, or if I was just missing something. Ah well.