By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,492 Members | 1,270 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,492 IT Pros & Developers. It's quick & easy.

TextBox Leave Event fires, but not every time

P: n/a
After a user enters data into a field, I need to populate other controls on
the form, based on the user entry. I have to use either Leave, Validating or
Validated, and I take it I can't use LostFocus because there is no selection
for that event in the dropdown list on the code page. What's happening is
that all 3 events mentioned above for the textbox control fire in the proper
order when the form is invoked, but don't fire the first time I tab or mouse
out of the textbox. After that, they fire on cue.

I am invoking a child form from an MDIForm. I have several controls on the
child form (Form1), but this concerns a textbox (TB0) with a TabIndex of 0.
I invoke the form from the MDIForm with the following code:

Form1= New Form1()
Form1.MdiParent = Me
Form1.PARENTFRM = Me
Form1.Show()

In a step-through, I see that the Leave Event for the TB0 fires when the
last line of the above code executes (not sure why Another TextBox on the
form with a coded Leave Event doesn't fire at this point, even if I set it's
TabIndex to 0, and TB0 to 1.) When the form opens, focus is on TB0. I enter
data, then tab or mouse out to another TextBox (TB1), whose TabIndex=1 and
CausesValidation=True. No Leave Event fires on TB0. However, when I
Shift-Tab or mouse back into TB0, then tab or mouse out again, the Leave
Event on TB0 does fire. The event will fire for as long as I have the form
open, but the only important instance (the first one) of the event is
skipped! I can't expect users to tab out of and back into a field, so I'm
pretty much stuck.

Help. Please.

JD
Jul 22 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Hi Jaydee,

You might want to try setting focus to a different control and then back
again to tb0 inside the form's load event, simulating the click out and
click back in.

HTH,

Bernie Yaeger

"JayDee" <Ja****@discussions.microsoft.com> wrote in message
news:FD**********************************@microsof t.com...
After a user enters data into a field, I need to populate other controls
on
the form, based on the user entry. I have to use either Leave, Validating
or
Validated, and I take it I can't use LostFocus because there is no
selection
for that event in the dropdown list on the code page. What's happening is
that all 3 events mentioned above for the textbox control fire in the
proper
order when the form is invoked, but don't fire the first time I tab or
mouse
out of the textbox. After that, they fire on cue.

I am invoking a child form from an MDIForm. I have several controls on
the
child form (Form1), but this concerns a textbox (TB0) with a TabIndex of
0.
I invoke the form from the MDIForm with the following code:

Form1= New Form1()
Form1.MdiParent = Me
Form1.PARENTFRM = Me
Form1.Show()

In a step-through, I see that the Leave Event for the TB0 fires when the
last line of the above code executes (not sure why Another TextBox on the
form with a coded Leave Event doesn't fire at this point, even if I set
it's
TabIndex to 0, and TB0 to 1.) When the form opens, focus is on TB0. I
enter
data, then tab or mouse out to another TextBox (TB1), whose TabIndex=1 and
CausesValidation=True. No Leave Event fires on TB0. However, when I
Shift-Tab or mouse back into TB0, then tab or mouse out again, the Leave
Event on TB0 does fire. The event will fire for as long as I have the
form
open, but the only important instance (the first one) of the event is
skipped! I can't expect users to tab out of and back into a field, so I'm
pretty much stuck.

Help. Please.

JD

Jul 22 '05 #2

P: n/a
Thank you Bernie, your suggestion pointed me in the right direction.
Switching the focus back and forth did work, but not in the form's load
event. I put it in the MDI form's menu click event, after the child form's
Show() event is called. That worked fine. Thanks a lot for your help.

"Bernie Yaeger" wrote:
Hi Jaydee,

You might want to try setting focus to a different control and then back
again to tb0 inside the form's load event, simulating the click out and
click back in.

HTH,

Bernie Yaeger

"JayDee" <Ja****@discussions.microsoft.com> wrote in message
news:FD**********************************@microsof t.com...
After a user enters data into a field, I need to populate other controls
on
the form, based on the user entry. I have to use either Leave, Validating
or
Validated, and I take it I can't use LostFocus because there is no
selection
for that event in the dropdown list on the code page. What's happening is
that all 3 events mentioned above for the textbox control fire in the
proper
order when the form is invoked, but don't fire the first time I tab or
mouse
out of the textbox. After that, they fire on cue.

I am invoking a child form from an MDIForm. I have several controls on
the
child form (Form1), but this concerns a textbox (TB0) with a TabIndex of
0.
I invoke the form from the MDIForm with the following code:

Form1= New Form1()
Form1.MdiParent = Me
Form1.PARENTFRM = Me
Form1.Show()

In a step-through, I see that the Leave Event for the TB0 fires when the
last line of the above code executes (not sure why Another TextBox on the
form with a coded Leave Event doesn't fire at this point, even if I set
it's
TabIndex to 0, and TB0 to 1.) When the form opens, focus is on TB0. I
enter
data, then tab or mouse out to another TextBox (TB1), whose TabIndex=1 and
CausesValidation=True. No Leave Event fires on TB0. However, when I
Shift-Tab or mouse back into TB0, then tab or mouse out again, the Leave
Event on TB0 does fire. The event will fire for as long as I have the
form
open, but the only important instance (the first one) of the event is
skipped! I can't expect users to tab out of and back into a field, so I'm
pretty much stuck.

Help. Please.

JD


Jul 22 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.