By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,688 Members | 1,888 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,688 IT Pros & Developers. It's quick & easy.

Display suggested completion for text box input. How?

P: n/a

As input is typed into a text box, I would like to search a recordset for the
first record that matches what has been typed so far. I would like to update
the text box to display the letters typed by the user in the normal font and
any additional characters in the first matching record displayed as highlighted
text. This matches the action of the MS Access help index.

I can use the OnKeyPress event to trigger a new check for the "best" match with
the recordset as input proceeds. I can display the input only but the user
can't tell if a match to what is being input has been found. I can store the
user input and display the recordset match, so both are still available in the
program. If I display the recordset value, it isn't obvious what has been input
so far (in other words, EXACTLY where the last letter typed is in the displayed
string)

I can display the best recordset match in a separate text box but my form is
already crowded.

I could use a combo box, opened programatically using the DropDown Method, and
programatically modifying the combo box list based on the current input string
and recordset values. The input field displays what has been typed so far and
the dropdown list shows only the first "likely" match from the recordset. I
find this method a little awkward.

How can I display the actual user input in the normal font and, in the same
text box, display the remainder of the "best" recordset value-if any?

Also, where will the cursor be? If the user types another letter with this
modified display in the text box, will the result be to add the new Key value
to the end of the previous user input or to the end of the recordset value
(which is displayed in mixed fonts). It seems, based on normal text box
behavior, I will need to catch the value of each Keypress and append it to the
user stored input string before searching the recordset for the best match.

Thanks in advance for any help.

Paul Core

Nov 12 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
On 10 Apr 2004 18:07:37 GMT, co******@aol.combvwertz (Corepaul) wrote:

I like a variant on your combobox approach: in the OnChange event wait
until at least 3 characters are typed, then start requerying the
back-end and display any hits (use the LIKE predicate in your query).

-Tom.


As input is typed into a text box, I would like to search a recordset for the
first record that matches what has been typed so far. I would like to update
the text box to display the letters typed by the user in the normal font and
any additional characters in the first matching record displayed as highlighted
text. This matches the action of the MS Access help index.

I can use the OnKeyPress event to trigger a new check for the "best" match with
the recordset as input proceeds. I can display the input only but the user
can't tell if a match to what is being input has been found. I can store the
user input and display the recordset match, so both are still available in the
program. If I display the recordset value, it isn't obvious what has been input
so far (in other words, EXACTLY where the last letter typed is in the displayed
string)

I can display the best recordset match in a separate text box but my form is
already crowded.

I could use a combo box, opened programatically using the DropDown Method, and
programatically modifying the combo box list based on the current input string
and recordset values. The input field displays what has been typed so far and
the dropdown list shows only the first "likely" match from the recordset. I
find this method a little awkward.

How can I display the actual user input in the normal font and, in the same
text box, display the remainder of the "best" recordset value-if any?

Also, where will the cursor be? If the user types another letter with this
modified display in the text box, will the result be to add the new Key value
to the end of the previous user input or to the end of the recordset value
(which is displayed in mixed fonts). It seems, based on normal text box
behavior, I will need to catch the value of each Keypress and append it to the
user stored input string before searching the recordset for the best match.

Thanks in advance for any help.

Paul Core


Nov 12 '05 #2

P: n/a

In my post, I forgot to mention that I am an Access newbie. After my post, I
continued to look around and found my answer in the Access VB Help file. The
SelLength and SelStart functions are the key.

I can store user input, keystroke by keystroke, in a local variable and display
the first recordset string whose beginning characters exactly match the current
user input. Set textbox.SelStart equal to the length of the user input string.
Set textbox.SelLength equal to the length of the recordset string minus the
length of the user input string. This leaves the typed input in normal font and
the remainder of the recordset string "selected." This is exactly what I wanted
to acomplish!

I'll need to handle when no match is found in the recordset (setting SelLength
to a negative number causes a run-time error) and other error handling issues.

Sorry to add to the bandwidth, I really did look for an answer before I posted
my request for help. Hunting for things in the Access help files is hit or miss
for me. I didn't get lucky until after I had posted. But, having raised the
question, I thought I'd post the answer I found.

Paul Core
Nov 12 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.