hertzgordman
asked on
Adding combo box for form created with data wizard
I have created a form using the data wizard. It works fine.
Want to change one control to a combo box. I am able the write the code that loads the combo box from the database.
I also bound the combo box to the dataset for the form.
The problem is that the combo box is not in synch with the form.
1. Is there any trick to bind it properly?
2. Do I need to add event code to have the combo box reflect the data in the current record?
Want to change one control to a combo box. I am able the write the code that loads the combo box from the database.
I also bound the combo box to the dataset for the form.
The problem is that the combo box is not in synch with the form.
1. Is there any trick to bind it properly?
2. Do I need to add event code to have the combo box reflect the data in the current record?
ASKER
Thanks
I will try this and let you know how it works
I will try this and let you know how it works
ASKER
Thanks
This helped.
It turns out I was not binding the combo to the correct table (i.e.MainTable).
I used the designer to do the bindings. Where were I put the above code if I wanted to do this as per above?
This helped.
It turns out I was not binding the combo to the correct table (i.e.MainTable).
I used the designer to do the bindings. Where were I put the above code if I wanted to do this as per above?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
On that basis, the bindings you want would be something like this
MyCombo.DataSource = SubsidiaryTable
MyCombo.DisplayMember = "Description" 'ie the field in the sub table that you want displayed
MyCombo.ValueMember = "ID" 'ie the Primary Key field in the sub table
MyCombo.DataBindings.Add("
If my assumptions are correct, and you can translate the above code OK for your set up, you shouldn't need any additional code to keep the combobox in synch with the other controls on the form.
Roger