473,385 Members | 1,492 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

TextBox Leave Event fires, but not every time

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
2 6101
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Chris Mayers | last post by:
Hi, I have an application that has (for the sake of argument) 2 (MDI) windows open. If I click into a textbox on FormA then the 'Enter' event for that TextBox fires, great! However, if I then...
5
by: Maxine G | last post by:
I have two forms, a menu and a data entry form. The entry form is bound to a query against linked SQL server tables. In the deactivate event, I have some code which asks the user if they want to...
2
by: MrNobody | last post by:
I notice that if you use the TextChanged event on a TextBox it will fire for every single change, like appending a single character- even if the user continues to type. I was wondering if there...
7
by: Itar | last post by:
I'm having a problem supressing characters in a text box. I only want alpha numeric characters (no special chars). I can handle the TextBox_KeyPress event to supress the invalid characters when...
4
by: miss_kait | last post by:
I would like to emulate the afterupdate event in vb.net after scanning a barcode. I have multiple barcodes to scan and after each scan I would like focus to move to the next text box. I have...
10
by: Dennis | last post by:
I have a simple form with one button and one text box. In the Form, I create an array list to track the events by adding a descriptive string item to the arraylist in each event. I first Click on...
2
by: JayDee | last post by:
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...
14
by: teddysnips | last post by:
WINDOWS FORMS I've a form that has a textbox that allows the user to enter a string. On the LostFocus event, the textbox formats the string into a preferred format. However, if the user...
2
by: jd | last post by:
I have several textboxes in which the end user can enter values. When the user presses the Enter key when in any of the textboxes, or leaves that textbox, I want a routine to run (mathematical...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.