Below is my code:
ByVal sDisplayfield As String, Optional ByVal sDatafield As String = "")
Dim i As Integer
'On Error GoTo EH
If Not rs.EOF Then rs.MoveFirst()
i = 0
While Not rs.EOF
this line works just fine: cmb.Items.Insert(i, rs.Fields(sDisplayfield).Value)
it display the name of the state
My problem is right here: I am trying to store the stateid in the same combobox. Visual basic 6.0 had an itemdata for the drop down box but 2005 does not have. I have seen a solution from Microsoft but cannot apply it to my concept below.
Any help is welcomed. Again, the code works fine. I just need to find a way to store the stateid in the dropdown.
Problematic line: 'If (Len(sDatafield) > 0) Then VB6.SetItemData(cmb, i, Val(rs.Fields(sDatafield).Value))
i = i + 1
Err.Description = "LoadCombobox-> " & Err.Description
Err.Raise(Err.Number, Err.Source, Err.Description)