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

Populating text box with combo box selections

P: 3
I am trying to populate a text box using combo box selections. so when the user clicks a selection in the combo box, a text box below will show the current selection, and the combo box will clear so the user can choose a new selection. here is my code so far:
Expand|Select|Wrap|Line Numbers
  1. Private Sub attributesComboBox_Click()
  2. Dim selectedAttribute As String
  3. selectedAttribute = attributesComboBox.text
  4. Debug.Print selectedAttribute
  5. End Sub
I tried populating the text box using a if statement like:
Expand|Select|Wrap|Line Numbers
  1. If selectedtextbox.text = "" Then
  2. selectedtextbox.text = selectedAttribute
  3. Else
  4. Selectedtextbox.text = selectedtextbox.text + selectedattribute
I know I would have to add some sort of loop to get multiple additions to the text box, but i couldn't even get this if statement to work so if anyone could give me some advice, that would be great thanks!
Jul 3 '14 #1
Share this Question
Share on Google+
1 Reply


twinnyfo
Expert Mod 2.5K+
P: 3,482
In098,

Please use Code tags when posting code. I think you may have some success starting with this:

Expand|Select|Wrap|Line Numbers
  1. Private Sub attributesComboBox_AfterUpdate()
  2.     Dim selectedAttribute As String
  3.     selectedAttribute = attributesComboBox.Column(0)
  4.     Debug.Print selectedAttribute
  5. End Sub
If your combo box has indexes and values associated with those values and you want the index, use the above. Otherwise, if your combo box has multiple columns, you can indicate the column in line 3 above (column 2 becomes Column(1)).

Hope this helps.
Jul 3 '14 #2

Post your reply

Sign in to post your reply or Sign up for a free account.