Home All Groups Group Topic Archive Search About

Text box - Change/Lost Focus use VB6

Author
2 Feb 2006 3:47 PM
Aaron
Hello all

I'm trying to save a record after leaving focus of a text box on a simple
form.  I have my retrieve & save file code working with Command buttons for
testing -- no problem there.

Coming from the Access/VBA world I'm accustomed to the After Update event,
VB6 has the Change and Lost Focus events.  But placing my save file code in
the Change event for a text box prevents my text box from operating
normal -- wont let me change the text value.

The Lost Focus does not work either(does not run my code I assume), but the
text box is not disabled.
I didn't want a manual Save/Store button.

Any ideas appreciated.

Author
2 Feb 2006 4:36 PM
Grant
If this is for the multiple text boxes, you better off having a save button
otherwise there is too much traffic going back and forth to the database. I
place a variable name form_dirty in change event for all text boxes. When
the user hits close or the x to close out of the form with out saving, I
will check to see if form_dirty is true and if it is then I ask them if they
want to save. My 2 cents



Lost Focus is the event you want to use and it will work once you move to a
different control.  Do not use the change event because every time a
character is entered into the box, the change event is fired.

Show quoteHide quote
"Aaron" <nom***@please.com> wrote in message news:2QpEf.7$Ax.0@fe04.lga...
> Hello all
>
> I'm trying to save a record after leaving focus of a text box on a simple
> form.  I have my retrieve & save file code working with Command buttons
> for testing -- no problem there.
>
> Coming from the Access/VBA world I'm accustomed to the After Update event,
> VB6 has the Change and Lost Focus events.  But placing my save file code
> in the Change event for a text box prevents my text box from operating
> normal -- wont let me change the text value.
>
> The Lost Focus does not work either(does not run my code I assume), but
> the text box is not disabled.
> I didn't want a manual Save/Store button.
>
> Any ideas appreciated.
>
>
>
Are all your drivers up to date? click for free checkup

Author
2 Feb 2006 4:45 PM
Aaron
I'm just writing the information to a Text.txt file for each of 4 fields.

Show quoteHide quote
"Grant" <em***@nowhere.com> wrote in message
news:%23aBTKdBKGHA.3852@TK2MSFTNGP09.phx.gbl...
> If this is for the multiple text boxes, you better off having a save
> button otherwise there is too much traffic going back and forth to the
> database. I place a variable name form_dirty in change event for all text
> boxes. When the user hits close or the x to close out of the form with out
> saving, I will check to see if form_dirty is true and if it is then I ask
> them if they want to save. My 2 cents
>
>
>
> Lost Focus is the event you want to use and it will work once you move to
> a different control.  Do not use the change event because every time a
> character is entered into the box, the change event is fired.
>
> "Aaron" <nom***@please.com> wrote in message news:2QpEf.7$Ax.0@fe04.lga...
>> Hello all
>>
>> I'm trying to save a record after leaving focus of a text box on a simple
>> form.  I have my retrieve & save file code working with Command buttons
>> for testing -- no problem there.
>>
>> Coming from the Access/VBA world I'm accustomed to the After Update
>> event, VB6 has the Change and Lost Focus events.  But placing my save
>> file code in the Change event for a text box prevents my text box from
>> operating normal -- wont let me change the text value.
>>
>> The Lost Focus does not work either(does not run my code I assume), but
>> the text box is not disabled.
>> I didn't want a manual Save/Store button.
>>
>> Any ideas appreciated.
>>
>>
>>
>
>
Author
2 Feb 2006 4:44 PM
Grant
put a msgbox "test" in lost focus event to test it out.

It should work.


Show quoteHide quote
"Aaron" <nom***@please.com> wrote in message news:0HqEf.11$3n1.3@fe05.lga...
> I'm just writing the information to a Text.txt file for each of 4 fields.
>
> "Grant" <em***@nowhere.com> wrote in message
> news:%23aBTKdBKGHA.3852@TK2MSFTNGP09.phx.gbl...
>> If this is for the multiple text boxes, you better off having a save
>> button otherwise there is too much traffic going back and forth to the
>> database. I place a variable name form_dirty in change event for all text
>> boxes. When the user hits close or the x to close out of the form with
>> out saving, I will check to see if form_dirty is true and if it is then I
>> ask them if they want to save. My 2 cents
>>
>>
>>
>> Lost Focus is the event you want to use and it will work once you move to
>> a different control.  Do not use the change event because every time a
>> character is entered into the box, the change event is fired.
>>
>> "Aaron" <nom***@please.com> wrote in message
>> news:2QpEf.7$Ax.0@fe04.lga...
>>> Hello all
>>>
>>> I'm trying to save a record after leaving focus of a text box on a
>>> simple form.  I have my retrieve & save file code working with Command
>>> buttons for testing -- no problem there.
>>>
>>> Coming from the Access/VBA world I'm accustomed to the After Update
>>> event, VB6 has the Change and Lost Focus events.  But placing my save
>>> file code in the Change event for a text box prevents my text box from
>>> operating normal -- wont let me change the text value.
>>>
>>> The Lost Focus does not work either(does not run my code I assume), but
>>> the text box is not disabled.
>>> I didn't want a manual Save/Store button.
>>>
>>> Any ideas appreciated.
>>>
>>>
>>>
>>
>>
>
>
Author
2 Feb 2006 5:55 PM
Karl E. Peterson
Grant wrote:
> put a msgbox "test" in lost focus event to test it out.
>
> It should work.

NEVER use a MsgBox to debug focus issues!!!  EVER.  PERIOD.  PARAGRAPH.

Just DO NOT do it!

This is VB's version of the Heisenburg Principle.

Can I be any clearer?
--
Working without a .NET?
http://classicvb.org/
Author
2 Feb 2006 6:22 PM
Grant
NO!!! You are not clear so please explain why we should not do it to test. I
do it all the time and this is not the change focus but the lost focus. I do
this to figure out which event is right place to put the codes in for
whatever I am trying to do.



Oh yeah, did you had to YELL!




Show quoteHide quote
"Karl E. Peterson" <k***@mvps.org> wrote in message
news:OWr0qHCKGHA.916@TK2MSFTNGP10.phx.gbl...
> Grant wrote:
>> put a msgbox "test" in lost focus event to test it out.
>>
>> It should work.
>
> NEVER use a MsgBox to debug focus issues!!!  EVER.  PERIOD.  PARAGRAPH.
>
> Just DO NOT do it!
>
> This is VB's version of the Heisenburg Principle.
>
> Can I be any clearer?
> --
> Working without a .NET?
> http://classicvb.org/
>
>
Author
2 Feb 2006 6:41 PM
Karl E. Peterson
Grant wrote:
> NO!!! You are not clear so please explain why we should not do it to
> test. I do it all the time and this is not the change focus but the
> lost focus. I do this to figure out which event is right place to put
> the codes in for whatever I am trying to do.

MsgBox's steal focus.  There are situations in life/science, where the
simple act of *observing* something alters what you see.  I'm sure you can
think of many such situations.  Consider taking candid photos of folks,
versus the "say cheese!" approach.  Well, in this specific case, debugging
focus issues, a MsgBox can and often does alter your results.  To insure
your observations don't affect the outcome, you need to use a method that
cannot change focus at all -- Debug.Print, for example.

> Oh yeah, did you had to YELL!

Can't help it on this one.  Nothing personal.  :-)
--
Working without a .NET?
http://classicvb.org/
Author
2 Feb 2006 7:27 PM
Gman
FWIW: in circumstances such as these I use Beep in order to signify a
section of code has been entered w/o interrupting program flow.
Particularly useful if you're running the binary rather than the
project. (It ain't great of course since you can only have one flavour
of Beep - although Beep Beep works in a pinch.)

Useful tip: Having your volume up reduces the number of times you'll
beat your head on the desk.

Karl E. Peterson wrote:
Show quoteHide quote
> Grant wrote:
>
>>NO!!! You are not clear so please explain why we should not do it to
>>test. I do it all the time and this is not the change focus but the
>>lost focus. I do this to figure out which event is right place to put
>>the codes in for whatever I am trying to do.
>
>
> MsgBox's steal focus.  There are situations in life/science, where the
> simple act of *observing* something alters what you see.  I'm sure you can
> think of many such situations.  Consider taking candid photos of folks,
> versus the "say cheese!" approach.  Well, in this specific case, debugging
> focus issues, a MsgBox can and often does alter your results.  To insure
> your observations don't affect the outcome, you need to use a method that
> cannot change focus at all -- Debug.Print, for example.
>
>
>>Oh yeah, did you had to YELL!
>
>
> Can't help it on this one.  Nothing personal.  :-)

Bookmark and Share