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

{SOLVED} combo box user updating 2nd column

P: 3
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
Nov 13 '06 #1
Share this Question
Share on Google+
4 Replies


MMcCarthy
Expert Mod 10K+
P: 14,534
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:

Expand|Select|Wrap|Line Numbers
  1.  
  2. Private Sub cmdAddData_Click()
  3. Dim rowSrc As String
  4.  
  5.   rowSrc = Me.Combo2.RowSource
  6.   rowSrc = rowSrc & ";'" & Me.txtNewData & "'"
  7.   Me.Combo2.RowSource = rowSrc
  8.  
  9. End Sub
  10.  
  11.  
This code will add whatever is in txtNewData to the combobox whenever the button is clicked.
Nov 13 '06 #2

P: 3
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:

Expand|Select|Wrap|Line Numbers
  1.  
  2. Private Sub cmdAddData_Click()
  3. Dim rowSrc As String
  4.  
  5.   rowSrc = Me.Combo2.RowSource
  6.   rowSrc = rowSrc & ";'" & Me.txtNewData & "'"
  7.   Me.Combo2.RowSource = rowSrc
  8.  
  9. End Sub
  10.  
  11.  
This code will add whatever is in txtNewData to the combobox whenever the button is clicked.
Many Thanks I'll give this a try
Nov 13 '06 #3

P: 3
I tried it and it worked first time, thank you.
Nov 14 '06 #4

MMcCarthy
Expert Mod 10K+
P: 14,534
I tried it and it worked first time, thank you.
No Problem

I'm marking this solved if no one has any objections.
Nov 14 '06 #5

Post your reply

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