I recently replaced the first routine below that I was using for a combobox, with the second routine below. The first one worked fine for the combobox, but did not meet my need to be able to display one value of the record, while using another value of the record, which caused me to change to the second routine. I.e., I wanted the colFullName value to be displayed in the combobox, but when I made a selection I wanted the valued from colContactID.
When the code is executed, the column names are expressed for the values of both cboOwner.DisplayMember, and cboOwner.ValueMember. e.g., "colFullName", and "colContactID"
Since this is a new approach for me, I have been unable to figure what I might have done to cause this issue.
Code:'cboOwner.Items.Clear() MasterBase.AddParam("@active", True) 'MasterBase.MasterBaseQuery("SELECT colFullName,colContactID FROMsitContacts WHERE colActive=@active") 'If RecordCount > 0 Then ' For Each r As DataRow In MasterBase.ListDataSet.Tables(0).Rows ' cboOwner.Items.Add(r("colFullName")) ' Next 'End If
Code:Public Sub GetOwnerComboBox() cboOwner.Items.Clear() cboOwner.Text = "" MasterBase.AddParam("@active", True) MasterBase.MasterBaseQuery("SELECTcolFullName,colContactID FROM sitContacts WHERE colActive=@active") cboOwner.DisplayMember ="colFullName" cboOwner.ValueMember ="colContactID" cboOwner.DataSource =MasterBase.ListDataSet.Tables(0) cboOwner.Text = ContactName End Sub




Reply With Quote
