data syn with text box

chowchow123

Active member
Joined
Sep 6, 2007
Messages
34
Programming Experience
1-3
Hi

I have a form which has a number of textboxes and some comboboxes. The text boxes are bound to the main table where the data will be save. The combo boxes have drop downs bound to another table - how do I link the data from the combobox to the main table i.e. anything that is in the combobox should be save in a field in the main table?

Thanks
 
Hi

I have a form which has a number of textboxes and some comboboxes. The text boxes are bound to the main table where the data will be save. The combo boxes have drop downs bound to another table - how do I link the data from the combobox to the main table i.e. anything that is in the combobox should be save in a field in the main table?

Thanks
The combo's display member and value member should both be set to the same column in the lookup table. The .SelectedValue databinding should then be bound to the relevant column in the main table

Click the combo
Choose properties
Look in the property grid
See (DataBindings) and expand it
See SelectedValue? Bind that to the main table
Look elsewhere
See DataSource? bind that to the lookup table
See DisplaMember?ValueMember? bind those to the columns in the lookup table
 
Hi

If I have say 3 comboboxes for month -

and I bind them as follows:
MonthDatasource1
MonthDatasource2
MonthDatasource3

Would I have to have the selected values as:

MainDataSource1
MainDataSource2
MainDataSource3

or can the selected value be identical?
 
All 3 combos can have a different lookup table and the same selected value, yes, but you must appreciate that they will all change in sync when you edit one, because they are all editing the same value!

Suppose you had 3 combos, showing numbers in languages from 3 lookup tables:
ID, Description
1, One
2, Two
3, Three

1, Ein
2, Zwei
3, Drei

1, Un
2, Deux
3, Trois

You bind one combo to the english, one to the german and one to the french. All 3 combo have their .SelectedValue bound to MyTable.WhatNumber

The combos will look like:
On, Ein, Un

You edit the english one to say TWO
The MyTable.WhatNumber becomes 2
The french and german boxes will see the change and update to say Ein, Deux


So, its kinda pointless to ahve 3 combos all editing the same value
 
thanks for the reply -

With a combobox you read the value from one table and save in another through selected values - How would it work with a textbox which reads values from one table but needs to save in another? - would it be an update query?
 
textbox isnt capable of doing that; why would a textbox have a lookup function? textbox are for free text entry, not lookup
 
Back
Top