Combo ValueMember troubles

rgreen

New member
Joined
Dec 4, 2002
Messages
3
Im having a real hard time trying to get this funtion to work correctly

Code:
Public Function PopulateListContol(ByVal ListControl As Object, ByVal ValMem As String, _
ByVal DisMem As String, ByVal Database As String, ByVal DataTable As String, ByRef ds As DataSet)
Try
connection stuff
Dim da As New OleDb.OleDbDataAdapter("SELECT * FROM " & DataTable, _
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Database)

da.Fill(ds)

ListControl.DataSource = ds.Tables(0)
ListControl.DisplayMember = DisMem 
ListControl.ValueMember = ValMem

Catch ex As Exception
MsgBox(ex.Message)
End Try
End Function

Im calling the function during a form load event in a block of code like
this:

Code:
declare the datasets
Dim dsClientCorp As New DataSet()
etc....

fill combo boxes 
PopulateListContol(Me.cboClientCorp, "ClientCorpID", "CompanyName", PathtoDB & ProjectDB, "ClientCorp", dsClientCorp)
etc...

So far so good, everything seems to work. All the combos populate with the CompanyName field from the correct tables. When I try to write to another table, the ValueMember isnt writing out correctly. The wrong number is being inserted everytime.

I have an access database that consists of 10 tables (Projects, ClientPvt, ClientCorp, Architect, Contractor, LandArch, ProjMan, QuantSurv, ServEng, StrucEng) All are address books except the Projects table which stores information related to jobs (this is a tool for managing job data in an Architectural practice).
 
Last edited by a moderator:
Back
Top