COMBO VALUE TO LIST

dubiousp

Member
Local time
Today, 17:07
Joined
Mar 6, 2020
Messages
86
I have list box that I would like to populate from a text box

Private Sub cbmedsearc_AfterUpdate()

Med_Name.AddItem (cbmedsearc.Value)

tried all sorts of differing routes but all fail
 
Hi. Is your Row Source Type set to Value List?
 
I have list box that I would like to populate from a text box

Private Sub cbmedsearc_AfterUpdate()

Med_Name.AddItem (cbmedsearc.Value)

tried all sorts of differing routes but all fail
Also, is your listbox meant to have just 1 column or multiple?
Remove the parenthesis
 
Also, is your listbox meant to have just 1 column or multiple?
Remove the parenthesis
I tend to use Me for form controls, and it works with or without parenthesis and with or without .Value

Code:
Private Sub txtSearchItem_AfterUpdate()
Me.cboSearchItems.AddItem (Me.txtSearchItem.Value)
End Sub
 
I tend to use Me for form controls, and it works with or without parenthesis and with or without .Value
Fair enough. "Remove the parenthesis" was a bit of a long shot ... I couldn't remember if they were truly disallowed, as I'm in the habit of never using parenthesis unless they're required: i.e. a Function or a Call keyword.

I was mostly thinking of multi columns and the potential need to use a) AddItem, b) .List(x)=something , etc. etc.
 
I only tried with one column, and made sure the combo was set to Value List.
Personally I see little point on this as, soon as I load the form I have to start all over again, however it was for an education exercise on my part.
 
Personally I see little point on this as, soon as I load the form I have to start all over again
I have found it useful for those occasional situations when for whatever reason the row source isn't going to be table driven and there are a small number of values that can be coded into the form load
 
THe text boxt is a look up a data table that contains about 150 different medications so my thought is to start typing in the text box when the medication it appears and can be added to a list of medications that a person is taking
 
Me.Med_Name.AddItem (Me.cbmedsearc.Column(1)) this gives invalid use of null error
 
you never answered the question, which is the Key solution.
What is the Row Source Type of the combobox ?(view it property sheet while in design view of your form).

if it is Value List, you need to use the AddItem method of the combo.
if it is Table/Query you need to Insert a record to your table and requery your combo.
 
Just FYI, this discussion continued on in this other thread.

 

Users who are viewing this thread

Back
Top Bottom