How to assign columns of two diferent tables to "valuemember" and "displaymember

Hello friends.

I have a quite peculiar problem.

I would like to have a combobox that showed values of a field (key primary of a table) and besides I would like to record this value in another different field of a diferent table (that it would be foreign key). I know that with ADO this fact was possible if you used the properties BoundColumn and BoundText of the DataCombo control, but with ComboBox control of VisualBasic.NET I cant.

I have filled up the DataSet with the two tables, Ive even established its relation, and Ive assigned the DataSet to the DataSource property of ComboBox control. Ive also assigned the name of the column that I want to the ValueMember property (like this: mydataset.Tables(0).Columns("mycolumn").tostring) and ive assigned the name of the other column of the other table to the DisplayMember property, in the same way. But the program sends a generic exception to me that does not help me much:"Cannot bind to the new display member.
Parameter name: newDisplayMember".

If you can help me I would be tremendously thankful .

Thank you very much!
[1131 byte] By [gd2q] at [2007-11-19 18:07:25]
# 1 Re: How to assign columns of two diferent tables to "valuemember" and "displaymember
If it is possible can u show us the code segment that u r working on and the exact point of error.
If i'm not mistaken, what u want to do is: display valueA from tableA, where the the valuemember of combobox should be valueB from tableB. right?
Are u populating the data at form load?
techsam at 2007-11-10 3:30:34 >
# 2 Re: How to assign columns of two diferent tables to "valuemember" and "displaymember
Thanks for answering!!

Yes, youre right!! I want to do exactly what you say.
And, effectively, I populate the data at form load.

The code is simple:

combobox1.datasource=mydataset
combobox1.displaymember=mydataset.tables("tableA").Columns("Pk_column").tostring
combobox1.valuemember=mydataset.tables("tableB").Columns("Fk_column").tostring

Thanks!

See you.
gd2q at 2007-11-10 3:31:30 >
# 3 Re: How to assign columns of two diferent tables to "valuemember" and "displaymember
I remember coming across a similar problem sometime during my training a few months back. Only i can't remember the work around. Gimme some time i'll get back to you ASAP.
Cheerio mate
techsam at 2007-11-10 3:32:40 >