G'day guys, I have been trying to use a combo box with two columns. In the first column I am listing 10 items from a table, in the second colum I would like the user to enter some data. The first column lists fine but I can't get anything into the second column. Hope you can help.
I'm using XP and Access 97
Thanks
To add items to a combo box (or a listbox for that matter) you need to do the following.
Assuming you don't want these values saved in a table.
Create a new textbox for entering the data to be added. Lets call it txtNewData.
Create a command button to put the code behind. Lets call it cmdAddData.
You don't give the name of the combobox so I'm calling it Combo2 for now.
Put this code in the On Click event of the command button:
-
-
Private Sub cmdAddData_Click()
-
Dim rowSrc As String
-
-
rowSrc = Me.Combo2.RowSource
-
rowSrc = rowSrc & ";'" & Me.txtNewData & "'"
-
Me.Combo2.RowSource = rowSrc
-
-
End Sub
-
-
This code will add whatever is in txtNewData to the combobox whenever the button is clicked.