Set Focus removes text from text box?

G

Guest

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.
 
G

Guest

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?
 
G

Guest

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.
 
A

Alex Dybenko

Thanks for update!
Alex

Quin said:
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top