Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

contents of txt box into combo box *as* the user types them

Status
Not open for further replies.

david2001

Technical User
Oct 2, 2001
24
0
0
GB
Hello,

I need to have what ever the user is typing in "txtbox1" automaticly be entered into cboBox1, *AS* the user types it letter by letter but with out changing the record source and so on of the combo box. They are both on frmForm1.

I know that this may not be the best way of doing things but there are very good reasons why I have to do this (unfortunatly).

Can some one suggest how I may do this as I have spent the last 2 days working on just this one small problem.

Thank you for your time,

david2001
 
on the on_Change even of the txtBox1:

ComboBox.text = txtbox1.text

HTH
Alcar
 
ok here it is again

on the onchange event of the textbox

combo.setfocus
combo.text=textbox.value
textbox.setfocus
textbox.selstart=len(text.text)

this should fix it =)

good luck
HTH
Alcar

p.s. sorry for before heheh
 
Don't let me interupt your search for a solution, but when you're done would you mind giving a brief explanation of why you're doing this? I see that no one else finds this odd, but unable to imagine the scenario, I have the puzzle sticking in the back of my head.
X-)
 
Hi Alcar,

Thank you for your kind reply and suggestion. I tried it exactly as you suggested but got the following error:

Compile error
Variable not defined, and the following line is high lighted in yellow "Private Sub txtbox1_Change()" and the left hand word "Text" from the line "= Len(Text.Text)" was highlighted in blue.

In case it matters, I am using Access 2000 and the limit to list property of the combo box is set to yes.

Any suggestions.

Kind regards,

David
 
instead of text.text put textbox1.text (or whatever your texbox is named =)
Alcar
 
Hi again Alcar,

Ok did that and this time as soon as i had typed ONE letter in i got:

Runtime '2237': The text you entered isnt an item on the list

and when i tried to backspace the letter in the text box i got:
Runtime error '94': Invalid use of null.

Wow for such a simple function as i need, access really dont seem to like it.

I hate to say this but do you have anything else to suggest coz this has me beaten.

Regards,

david
 
Hi fellow forum members,

I still need help with this problem if anyone can suggest anything - its really driving me mad. Such a hard thing to do for such a simple task.

Kind regards,

david
 
David,

I work with A97 so there may be something with 2K that differs, but it seems that what you're trying to do cannot work as long as limit to list is yes.

When you set the focus back to the textbox, you are triggering the afterupdate event of the combo box just as if you had hit enter or tabbed out of it. Since the text is not an item in the list, you will generate that error.

I think TempClerk's question is an important one. The combobox affords you the AutoExpand property that searches for the text you type as you type it. The only difference (that I can think of) is that you may wish to avoid the autofill of the combo's textbox while typing but still scroll the list to get your user closer to the selection.

If this is the case, you might want to consider a listbox and an unbound textbox. In the criteria for the listbox query, try
Code:
[TextBox] & "*"
. and on the Change or KeyPress of the textBox,
Code:
Listbox.Requery
.

HTH


John
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top