So you are working in Database app where you want to store code and display descriptions. while fetching data obviously you'll have to use left/right inner/outer joins to bring code and descriptions. While loading combo you can use itemdata to store numeric codes. To invariably store the code first additem the description append it with space$(100) and after that the code. Now the code will not be seen by user. now while you want to get the code of the selected item use the below one line function. i have given function for both code returning and description returning for a selected item in a combo box.
Public Function GetCode(cboCtl As ComboBox) As String
GetCode = Trim(Right$(cboCtl.List(cboCtl.ListIndex), Len(cboCtl.List(cboCtl.ListIndex)) - InStr(1, cboCtl.List(cboCtl.ListIndex), Space$(100), vbTextCompare)))
End Function
Public Function GetDescription(cboCtl As ComboBox) As String
GetDescription = Trim(Left$(cboCtl.List(cboCtl.ListIndex), InStr(1, cboCtl.List(cboCtl.ListIndex), Space$(100), vbTextCompare)))
End Function
This logic works easy and no reengineering. only in VB7 you have additional functionality of combo to store the codes. I'm using this logic for last 4 years and works fine.
All the best
RV
rv_ooty@hotmail.com