That got me there Paul. I added the line,RecordCount = ListAdapter.Fill(ListTable)
ListDataSet.Tables.Add(ListTable)to my connection class (MasterBaseConn).Code:ListDataSet.Tables.Add(ListTable)
After removing the combobox.ValueMember and the combobox.DisplayMember from the GetDeptList() routine the for Each Next loop ran exactly as expected and the combobox was able to do it's job. Apparently, with caveats.
The combobox is handled using the routine GetDeptList(), shown below.
This above routine is called from SetState()Code:Private Sub GetDeptList() MyQuery = "Department ComboBox query" cboDept.Items.Clear() MasterBase.MasterBaseQuery("SELECT colDept FROM lkpDept") If RecordCount > 0 Then For Each r As DataRow In MasterBase.ListDataSet.Tables(0).Rows cboDept.Items.Add(r("colDept")) Next cboDept.DataSource = MasterBase.ListDataSet 'cboDept.ValueMember = "colDept" 'cboDept.DisplayMember = "colDept" cboDept.SelectedIndex = -1 ElseIf MasterBase.Exception <> "" Then MsgBox(MasterBase.Exception) End If End Sub
After I created the new record and used the combobox, I closed that form and returned to the list form, which now showed the newly created record in DGVList on the form. I clicked the record in the DGVList which opened the record form to that record and it was here that the error occurred when SetState() was called.Code:Private Sub SetState(ByVal appstate As String) #Region "Color Pallet" #End Region #Region "Default Form Properties" Text = "Employee Record" #End Region #Region "Default Button Properties" btnEdit.Enabled = True btnSave.Enabled = True btnScan.Enabled = False btnCancel.Enabled = True btnClose.Enabled = True btnHelp.Enabled = False #End Region #Region "Default Control Properties" pnlRecord.Enabled = True lblStaffID.Enabled = False txtFirst.ReadOnly = False txtMiddle.ReadOnly = False txtLast.ReadOnly = False txtTitle.ReadOnly = False txtEnd.ReadOnly = False cboDept.Enabled = True cboDept.Sorted = True GetDeptList() txtDetail.ReadOnly = False rdoActive.Enabled = True rdoObsolete.Enabled = True #End Region Select Case appstate #Region "Case Add" Case "Add" btnEdit.Enabled = False btnClose.Enabled = False cboDept.SelectedIndex = -1 #End Region #Region "Case Edit" Case "Edit" btnEdit.Enabled = False btnClose.Enabled = False #End Region #Region "Case View" Case "View" btnCancel.Enabled = False btnSave.Enabled = False txtFirst.ReadOnly = True txtMiddle.ReadOnly = True txtLast.ReadOnly = True txtTitle.ReadOnly = True txtEnd.ReadOnly = True cboDept.Enabled = False txtDetail.ReadOnly = True rdoActive.Enabled = False rdoObsolete.Enabled = False #End Region End Select End Sub
I read the exception as telling me that the combobox setting is a one time thing and cannot be recreated. That does not seem right to me. If you can tell me where/what I am still doing wrong you could save what little hair I have left, after already pulling most of it out over this.




Reply With Quote
