Group:  Microsoft Access » microsoft.public.access.modulesdaovba
Thread: Set Focus removes text from text box?

DotNetBag
.NET Development Newsgroups

HTVi
TV Discussion Newsgroups

Our Hot Pick: Rising Antivirus 2006 - Certified by TUV & Checkmark! Get 10% discount by entering this coupon code: ONDISCOUNT10
Rising Antivirus 2006

Set Focus removes text from text box?
Quin 23.09.2006 04:44:01
In my form When I use SetFocus on a text box in the "Keyup" event I find that
I can only enter one single letter into the text box. If I try to enter the
next letter of a word or name, the first letter disapears! Probably because
my text box "updates" with the form. I need to have each character entered
into the text box remain after each update until they are deleted or
backspaced out of the text box.

Here is the actual sub.

Private sub textbox_Keyup
Textbox.SetFocus
Me.Requery
End Sub

The goal is to enter text letters one at a time and update the form every
time I add an additional letter. This same code gives the correct result in
Access 97 but will not work in newer versions of access.

If I comment out the Textbox.set focus the form works but the focus is
always in the wrong place.

I will be glad to provide more information if it is needed.



Re: Set Focus removes text from text box?
"Alex Dybenko" <alexdyb[ at ]PLEASE.cemi.NO.rssi.SPAM.ru> 24.09.2006 07:39:27
Hi,
perhaps Me.Requery causes lost of a focus, so try to set focus after it;
also you can try to use tab order to set this textbox to be first in order

--
Best regards,
___________
Alex Dybenko (MVP)
http://alexdyb.blogspot.com
http://www.PointLtd.com

"Quin" <Quin[ at ]discussions.microsoft.com> wrote in message
news:1F7731C3-251C-40BF-B9D8-8AFC4E0B68C1[ at ]microsoft.com...
[Quoted Text]
> In my form When I use SetFocus on a text box in the "Keyup" event I find
> that
> I can only enter one single letter into the text box. If I try to enter
> the
> next letter of a word or name, the first letter disapears! Probably
> because
> my text box "updates" with the form. I need to have each character
> entered
> into the text box remain after each update until they are deleted or
> backspaced out of the text box.
>
> Here is the actual sub.
>
> Private sub textbox_Keyup
> Textbox.SetFocus
> Me.Requery
> End Sub
>
> The goal is to enter text letters one at a time and update the form every
> time I add an additional letter. This same code gives the correct result
> in
> Access 97 but will not work in newer versions of access.
>
> If I comment out the Textbox.set focus the form works but the focus is
> always in the wrong place.
>
> I will be glad to provide more information if it is needed.
>
>
>

Re: Set Focus removes text from text box?
Quin 25.09.2006 17:02:02
Alex,
Thanks for taking the time to reply. Your thoughts on this were excellent.
I was sure that setting the tab order was going to work. It turns out that
when I set the tab order the form updates with each keystroke as intended but
after each update the text in my text box is "selected" which causes the
previous text to delete when I enter additional text. Is this normal
behavior after a me.requery?

This seems like such a simple thing but it sure is causing me a problem.
Anyone else have any ideas?






"Alex Dybenko" wrote:

[Quoted Text]
> Hi,
> perhaps Me.Requery causes lost of a focus, so try to set focus after it;
> also you can try to use tab order to set this textbox to be first in order
>
> --
> Best regards,
> ___________
> Alex Dybenko (MVP)
> http://alexdyb.blogspot.com
> http://www.PointLtd.com
>
> "Quin" <Quin[ at ]discussions.microsoft.com> wrote in message
> news:1F7731C3-251C-40BF-B9D8-8AFC4E0B68C1[ at ]microsoft.com...
> > In my form When I use SetFocus on a text box in the "Keyup" event I find
> > that
> > I can only enter one single letter into the text box. If I try to enter
> > the
> > next letter of a word or name, the first letter disapears! Probably
> > because
> > my text box "updates" with the form. I need to have each character
> > entered
> > into the text box remain after each update until they are deleted or
> > backspaced out of the text box.
> >
> > Here is the actual sub.
> >
> > Private sub textbox_Keyup
> > Textbox.SetFocus
> > Me.Requery
> > End Sub
> >
> > The goal is to enter text letters one at a time and update the form every
> > time I add an additional letter. This same code gives the correct result
> > in
> > Access 97 but will not work in newer versions of access.
> >
> > If I comment out the Textbox.set focus the form works but the focus is
> > always in the wrong place.
> >
> > I will be glad to provide more information if it is needed.
> >
> >
> >
>
>
Re: Set Focus removes text from text box?
Quin 30.09.2006 17:38:01
I now have my form working correctly. I made several changes which resulted
in success. I went to “tools, options, keyboard” and set "Go to end of
field". I also went to "view menu, tab order" and set my text box as first
in line for focus. That eliminated any need to set focus in code. The only
code I needed was Me.Requery.

Another possible problem with my form was that I named the text box
“Textbox”. That word is probably a keyword that is reserved in Access. I
renamed it and with all the changes listed above I was able to get the form
to work as desired.




"Quin" wrote:

[Quoted Text]
> Alex,
> Thanks for taking the time to reply. Your thoughts on this were excellent.
> I was sure that setting the tab order was going to work. It turns out that
> when I set the tab order the form updates with each keystroke as intended but
> after each update the text in my text box is "selected" which causes the
> previous text to delete when I enter additional text. Is this normal
> behavior after a me.requery?
>
> This seems like such a simple thing but it sure is causing me a problem.
> Anyone else have any ideas?
>
>
>
>
>
>
> "Alex Dybenko" wrote:
>
> > Hi,
> > perhaps Me.Requery causes lost of a focus, so try to set focus after it;
> > also you can try to use tab order to set this textbox to be first in order
> >
> > --
> > Best regards,
> > ___________
> > Alex Dybenko (MVP)
> > http://alexdyb.blogspot.com
> > http://www.PointLtd.com
> >
> > "Quin" <Quin[ at ]discussions.microsoft.com> wrote in message
> > news:1F7731C3-251C-40BF-B9D8-8AFC4E0B68C1[ at ]microsoft.com...
> > > In my form When I use SetFocus on a text box in the "Keyup" event I find
> > > that
> > > I can only enter one single letter into the text box. If I try to enter
> > > the
> > > next letter of a word or name, the first letter disapears! Probably
> > > because
> > > my text box "updates" with the form. I need to have each character
> > > entered
> > > into the text box remain after each update until they are deleted or
> > > backspaced out of the text box.
> > >
> > > Here is the actual sub.
> > >
> > > Private sub textbox_Keyup
> > > Textbox.SetFocus
> > > Me.Requery
> > > End Sub
> > >
> > > The goal is to enter text letters one at a time and update the form every
> > > time I add an additional letter. This same code gives the correct result
> > > in
> > > Access 97 but will not work in newer versions of access.
> > >
> > > If I comment out the Textbox.set focus the form works but the focus is
> > > always in the wrong place.
> > >
> > > I will be glad to provide more information if it is needed.
> > >
> > >
> > >
> >
> >

Home | Search | Terms | Imprint | Contact
Newsgroups Reader - provided by WiredBox.Net