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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Very simple Q about populating a text box based on combo box selection

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
Hi.

I am attempting to put together a storyboard (click-through demo) for our next generation product and am fumbling my way through it.

Anyway, my simple question is how do you dynamically populate a text box (say Text1) based on the value selected in a dropdown combo box (say Combo1) at runtime? I do not require an elegant solution, so assume there are only two items in the combo box for the user to select at runtime.

Thanks,

--Dan
 
Hi,

Private Sub Combo1_Click()
Text1.Text = Combo1.List(Combo1.ListIndex)
End Sub

Have a good one!
BK
 
Hi...thanks for your response but...

Now I feal like a real buffoon. I tried the suggestion and got a Compile Error: Method or data member not found and it was pointing to .ListIndex

Basically the autofill when I type Combo1. is about 4 items (Count, Index, and 2 others).

Any ideas?

Thanks,

--Dan
 
Hi,

Hmmmm...that doesn't sound right. Are you using a VB standard combobox? Are you sure "combo1" is the name of your combobox? I copied/pasyed the code from my message back into a project and it worked fine.

Have a good one!
BK
 
Thanks again for the response.

You know you are right...If I start a new form with a brand new combo box, everything seems to work properly.

Well I must have changed something on that standard combo box to make behave differently.

Ah well...problem solved...thanks

--Dan
 
Dan
Sounds to me like the original form had a control array for combo1. If you typed combo1(1). or whatever index it is, you should get all the intellisense options.
Mick
 
Mick,

Think you hit the nail on the head on that one.

These 1200 page books on VB are great until you have a "strange" problem :)

Makes sense though because when I deleted the original CB and added a new one, everything worked like a charm.

So the next question is, how did it "become" a combo array? I assume the good ol cut & paste got me again?

Cheers,

--Dan
 
you probably copied and pasted it and when it asked you if you wanted to make combo1 a control array you clicked yes. ----------------
Joe
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top