View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
JLGWhiz JLGWhiz is offline
external usenet poster
 
Posts: 3,986
Default Exit event/textbox/frame

I thought that it might work by putting the executatble code in the standard
module and use the exit event to call it. It worked pretty good going one
way, but when I went back to Frame one it would stop after executing textbox4
code, it continued on and executed the exit event for textbox1. That blew my
mind. I haven't figured that out yet. I think you might have to come up
with an alternative way to do what you want, like don't use the Frames. Just
organize your text boxes on the form in the groups as though they were in
frames.

"Flemming Jørgensen" wrote:

Cant get it to work

Now when I tab out of textbox2 the frame_exit start - and it shouldn't
because there are 3 boxes in the frame..

Here is my code
Private Sub Frame1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
Call TextBox3_Exit(ByVal Cancel)

End Sub
Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
'This is 1st textbox in Frame1
FeltNr = 2
If Not Valid(FeltNr, "Varme for Hovedmåler") Then
Cancel = True
End If
End Sub
Private Sub TextBox2_Exit(ByVal Cancel As MSForms.ReturnBoolean)
'This is 2nd textbox in Frame1
FeltNr = 3
If Not Valid(FeltNr, "Vand for Hovedmåler") Then
Cancel = True
End If
End Sub
Private Sub TextBox3_Exit(ByVal Cancel As MSForms.ReturnBoolean)
'This is 3rd textbox in Frame1
FeltNr = 4
If Not Valid(FeltNr, "Varme for K12") Then
Cancel = True
End If
End Sub
Private Sub TextBox4_Exit(ByVal Cancel As MSForms.ReturnBoolean)
'This is 1st textbox in Frame2
FeltNr = 5
If Not Valid(FeltNr, "El for K12") Then
Cancel = True
End If
End Sub


"JLGWhiz" wrote:

I did a little memory refresh on my own head and here is where the problem
lies. The Exit event for a control on a form or in a container such as the
TextFrame, will only fire when the destination is within the immediate
container. That is why it worked for you for the first two tabs within the
same TextFrame but failed when you tabbed to a different frame. I
incorrectly assumed that no exit event applied to the TextFrame since none
was listed in the VBA help file. However, when you check the declarations
menu in the VBA code window for a TextFrame, it lists the exit event. So I
tried it, it works.

The answer to your problem is to use the Exit event of the TextFrame when
moving between Frames. Use the Exit event of the TextBox (or other controls)
when moving between controls withing the same container. Good Luck.

"Flemming Jørgensen" wrote:

I agree. Didn't write that either I think.

As an example.

I have 3 textboxes in 1 frame - When I leave textbox1 and textbox2 with
tab-key, the exit_event start.
But when I tab out of textbox3(last in frame1) into textbox4(first in
frame2) - the exit_event dosn't start.



"JLGWhiz" wrote:

I don't believe the TextFrame supports any events, it just acts as a
container for other objects.

"Flemming Jørgensen" wrote:

Hi guys

I have several groups of textboxes on my form - all surrounded by frames.
For validation I have a exit_event for each textbox.

But when I tab thru my textboxes the exit_event dosn't start on the last
textbox i a frame. and that goes for all the frames.

Can somebody please help?
Regards,
Flemming