Recording spaces from spacebar:

R

Ross

I am doing Keystroke by Keystroke Lookups of information using wildcards.

After a single keystroke, I move focus out of the field of a form (to record
the update to the field) and then bring focus back into the field to allow
the user to enter additional keystrokes. When focus returns to the field,
the cursor masks the entire field. I want the cursor to move to the end of
the field after the “On Change†event has finished its query of the current
keystroke string.

For example: If the first Keystroke is “Bâ€, I will get “Bookâ€, “Bank†and
“Boy†in my listbox. Then cursor moves to the end of the string after the
lookup is complete and the user can then type “o†to return “Boy†and “Bookâ€.

I have found that this code will move the cursor to the end to the text box
field in a form in anticipation of the user entering the next keystroke:

SendKeys "{F2}"

This works perfectly until the user needs a Space in the lookup string like
“Boy Girlâ€. The Sendkeys code removes the space in the string so
that you will get “Boy†instead of “Boy “. Ultimately, you will get only
"BoyGirl". How can I move the cursor to the end of the text box and preserve
a space in the string when the spacebar has been hit?

OR

Is there another way to do Keystroke by Keystroke lookups?

Thank you

Ross
 
S

Stuart McCall

Ross said:
I am doing Keystroke by Keystroke Lookups of information using wildcards.

After a single keystroke, I move focus out of the field of a form (to
record
the update to the field) and then bring focus back into the field to allow
the user to enter additional keystrokes. When focus returns to the field,
the cursor masks the entire field. I want the cursor to move to the end of
the field after the “On Change” event has finished its query of the
current
keystroke string.

For example: If the first Keystroke is “B”, I will get “Book”, “Bank” and
“Boy” in my listbox. Then cursor moves to the end of the string after the
lookup is complete and the user can then type “o” to return “Boy” and
“Book”.

I have found that this code will move the cursor to the end to the text
box
field in a form in anticipation of the user entering the next keystroke:

SendKeys "{F2}"

This works perfectly until the user needs a Space in the lookup string
like
“Boy Girl”. The Sendkeys code removes the space in the string so
that you will get “Boy” instead of “Boy “. Ultimately, you will get only
"BoyGirl". How can I move the cursor to the end of the text box and
preserve
a space in the string when the spacebar has been hit?

OR

Is there another way to do Keystroke by Keystroke lookups?

Thank you

Ross

Replace your SendKeys statement with the following code:

With Me.ControlName
.SelStart = 256
.SelLength = 0
End With
 
J

John Spencer

Don't move the focus from the control. When you do the trailing space is
automatically removed.

You should be able to use the TEXT property of the control to do your
keystroke lookups. Without knowing your code that is all I can suggest.

You might take a look at Expanding Search at
http://www.datastrat.com/Download2.html

Arvin Meyer has code that allows you to type into a textbox and change the
selection in a listbox. You should be able to use that code as an example
to do what you are attempting.



--
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
..
 

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