VB Code:
' For reference, any rsToUSe that is passed to this method is a Private ADODB.Recordset on the Form with the DataCombo on it
Private Sub PopulateList(ByVal TableName As String, ByRef cmb As DataCombo, ByRef rsToUse As ADODB.Recordset, Optional ByVal ColumnToDisplay As String = "Description", Optional ByVal ColumnToStoreInTable As String = "Code", Optional ByVal OptionalSQL As String)
' This Sub fills a Record Set (rsToUSe) with the two selected columns (strColumnToDisplay and
' strColumnToStoreInTable) from a table (dbTable) and then uses the Record Set to populate a
' DataCombo box (cmbBox) with the values in the Table
Set rsToUse = New ADODB.Recordset
rsToUse.CursorLocation = adUseClient
rsToUse.Open "SELECT [" & ColumnToStoreInTable & "], [" & ColumnToDisplay & "] FROM [" & TableName & "] " & OptionalSQL, fmMain.conn, adOpenStatic, adLockReadOnly
Set cmb.RowSource = rsToUse
cmb.ListField = ColumnToDisplay
cmb.BoundColumn = ColumnToStoreInTable
' x is defined elsewhere
cmb.BoundText = x ' setting the BoundText reports no error if x is an item > index 50, it just remains ""
cmb.MatchEntry = dblExtendedMatching
End Sub