#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 34
Default Userforms

Hello,

I have a form with two frames on it. Each frame has a few controls. In
the exit event of the controls I reformat the text to correct user entry
errors. The problem I have is that when a user tabs out of the last control
on a form the exit event does not fire until the user tabs back into the
frame. Is there a way around this? And second... In one exit event I verify
the integrety of the data and if incorect I set the focus back to the control
but this does not seem to work. Can you not set focus in the exit event?

Thanks,
Ernst.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 42
Default Userforms

"Ernst Guckel" wrote:
The problem I have is that when a user tabs out of the last control
on a form the exit event does not fire until the user tabs back into the
frame. Is there a way around this? And second... In one exit event I verify
the integrety of the data and if incorect I set the focus back to the control
but this does not seem to work. Can you not set focus in the exit event?


I'm not sure why this happens, but the exit event for the frame is firing
instead of the exit for the last control. Then when you come back into the
frame, it fires the last control's exit event. I don't know why it thinks
you need it then.

Maybe you could put the validation code for the last control in an
independent method and call it when the frame exit fires. That will break,
though, if you ever change the tab order or add another control. I hope
someone else has a better solution.

As for focus: if you set the Cancel variable to True inside the Exit Event
handler, the control will not give up its focus. If you want to select the
text in a textbox, I believe you have to do that with the .SelStart &
..SelLength properties.

If (bad condition) Then
Cancel = True
With TextBox1
.SelStart = 0
.SelLength = Len(.Text)
End With
end if
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 42
Default Userforms

"Ernst Guckel" wrote:
the exit event does not fire until the user tabs back into the
frame.


I found some more frame event peculiarities:

Frame is consistent about intercepting exit events. If you Shift-Tab and
leave the first control in the frame, that control's exit event won't fire.
So if you try to do validation in the frame exit event, you have to test all
the controls, I guess. If you click out of the frame, the last control with
focus won't fire its exit event.

I can't make sense of the enter event on the first control. Sometimes it
fires, sometimes it doesn't. If I just tab straight through the form, it
will fire on entry, but if I shift-Tab back to the first frame, then tab back
in, it won't fire.

Also, if instead of tabbing through controls, you click into the second
control of the second frame while a control in the first frame has focus, the
Enter event of the second frame's *first* control fires. That is, even if
you leap-frog over the first control of the second frame, its enter event
fires.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 34
Default Userforms

I found some more frame event peculiarities:

Frame is consistent about intercepting exit events. If you Shift-Tab and
leave the first control in the frame, that control's exit event won't fire.
So if you try to do validation in the frame exit event, you have to test all
the controls, I guess. If you click out of the frame, the last control with
focus won't fire its exit event.


Exactly... I can recreate this time and time again but I just don't
understand why it does it. But I worked around it through the frame exit
event...

Thanks for the help.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Help with Userforms Panagiotis Marantos Excel Discussion (Misc queries) 2 July 25th 06 04:26 PM
I need some help with userforms T.c.Goosen1977 Charts and Charting in Excel 0 June 30th 06 09:29 AM
I need some help with userforms T.c.Goosen1977 Excel Discussion (Misc queries) 0 June 30th 06 09:27 AM
Esc out of userforms Mark \(InWales\)[_23_] Excel Programming 2 February 2nd 05 10:08 PM
userforms Fretsa Excel Programming 1 July 27th 04 12:52 AM


All times are GMT +1. The time now is 02:48 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"