Writing data to Combo Boxs

lroy1978

Registered User.
Local time
Today, 10:03
Joined
Jan 11, 2006
Messages
22
Hi All,
I am trying to write some data into a Combobox that has a column count of 2 using VB. Ie, I would like to write the fields first_name and last_name into the box.

I can do it for a column count of one, say writing just :

combobox1 = "Lee"

But for multiple values I have no idea.

Does anyone know how to do this?

Many Thanks,
Lee
 
Combobox store one value but may display many.
Are you asking how to populate the Rowscource from code? Your example just sets the value of the control for the bound column.

Peter
 
Thanks for the response Peter. Indeed, yes, I am asking how to populate the Rowsource from code.
 
I try the following:

Company.RowSource = "1";"test 1";"2";"test 2";"3";"Test 3"

But I just keep getting the error message :

Compile Error

Expected: end of statement
 
The colons need to be in the string
Company.RowSource = "1;test 1;2;test 2;3;Test 3"

Peter
 
Thanks Peter. That has sorted out the compile error problem!

Its still not quite what I need. I have several combo boxs, a couple of them having a column count of one. I need to update them every time I change to a different record so that the visible contents of the combobox (ie the data displayed without having to make a selection from the combo) are immediately evident.

I can set the visible text without problems using:

NameOfCombobox = "Text to display"

I also however have several comboboxs with a column count of 2 or more. And I cant seem to seem to do the same thing with these comboboxs, they simply remain blank.

I have tried using rowsource, but one can only view the changes to the data by clicking on the combobox, I need the values to be visible straight away without clicking on the combo.

Does that make sense? Any idea on how to do this?

Many thanks once again for your help.

Lee
 
If the comboboxes are bound then they will reflect the data in the record they are bound to and will update themselves when you change record.
if unbound then setting the value should show the data but remember to set the value of the bound column. This should show test 2
Company.RowSource = "1;test 1;2;test 2;3;Test 3"
Company = 2

edit : this assumes that the first column is bound and has its width set to 0 :)

HTH

Peter
 
Just a quick question about this topic. Isn't coding it this way only a temporary way to write to the rowsource? I read that in one of my reference books and was just curious. :)
 
yep, just tempoary but can be useful to build custom combos

Peter
 

Users who are viewing this thread

Back
Top Bottom