Hi all
I am trying to Populate a combo box from a selection in an adjacent
Listview. The Listview lists as a string the field names of 4
different fields in tblFile. So far I can populate the combo box with
the correct number of records(only 4 in the test database) but the
data is the actual string being passed which is actually the right
field....just not the data in the field. Here is my code so far that
fills the combo box with the string Name.
' selects the field name used for the table tblFile
strID = lvSearchBy.SelectedItems(0).SubItems(1).Text
intID = CInt(Val(Trim(strID)))
'Gets field name from tblSearch
dbCmd.CommandText = "Select ActualName from tblSearch where IDKey = "
& intID & " "
dbConn.Open()
dbReader = dbCmd.ExecuteReader()
dbReader.Read()
strName = Trim(dbReader!ActualName)
dbConn.Close()
dbReader.Close()
dbConn.Open()
dbCmd.CommandText = "Select '" & strName & "' from tblFile order by '"
& strName & "' "
dbReader = dbCmd.ExecuteReader()
cboSearch.Items.Clear()
Do While dbReader.Read()
cboSearch.Items.Add(dbReader(0))
Loop
dbConn.Close()
Result in the combo box is:
wkrName
wkrName
wkrName
wkrName
There are 4 records in the test database.....so the number of records
are correct. I need to get the value of the wkrName field in the
table tblFile.
Your help would be apprieciated.
Thanks
Dave McKie
da*********@yahoo.com
9/30/2004