Combobox selectedindex = -1 and 0 not working

G

Guest

I posted this last night and didn't know how to crosspost.

I have a form with 4 combo boxes and several text boxes.
All combos are filled in the form load event.
The first combobox contains names and this is the code to
fill it:

'istantitiate data tier object
mobjUnityGroup = New UnityGroupData

'get the list of names from the data tier
dvNames = mobjUnityGroup.getNames

With cboName
.DataSource = dvNames
.DisplayMember = "Name"
.ValueMember = "ChildID"
.SelectedIndex = -1
End With

All other combo boxes are filled at the same time and the same way (with
different datasource, display member, valuemember).

I select a name and in the selectedindexchanged event, the fields are filled
in and bound to the form. That works fine. However, after editing the
record and saving, by clicking the Save button on the form, I wish to clear
all fields, including the combo boxes. All combo boxes clear except the
cboName.

I another procedure I am setting all combo boxes' selectedindex = 0 and then
selectedindex = -1 per the bug. All works fine except for the name combo
box. I am getting an error "Object reference not set to an instance of the
object" when the code reaches cboName.selectedindex = -1.

Anyone have any idea why this is happening?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top