Setting ListIndex with Text Value, without User Interaction...
Posted on 2003-11-07
Here is what im doing. I populate the Combo Boxs with values from a database, which sets the text values and the Itemdata that corresponds to the text value.
Then I retreive values the text values from the database that corresponds to whatever record the user wants to display.
Here is the problem:
When the user finds a record and then edits a record, but just edits one field, the other Combo Boxs remain at a listindex of -1. So when I attempt to UPDATE my database, and retreive the ItemData using - field = cbo.ItemData(cbo.ListIndex). I get an error.
Part of Code:
strSQL = "UPDATE tblMaster " & _
"SET CountyID = " & cboCounty.ItemData(cboCounty.ListIndex) & _
", RouteID = " & cboRoute.ItemData(cboRoute.ListIndex) & _
", PostMile = " & txtPostMile.Text & _
", MaterialID = " & cboMaterial.ItemData(cboMaterial.ListIndex) & _
", DetailID = " & cboDetail.ItemData(cboDetail.ListIndex) & _
", vDate = " & txtDate.Text & _
", Comments = " & txtComments.Text & _
" WHERE PKey = " & lblPKey.Caption
So how would I get the proper listindex through code?