I have the following code to fill a Combo Box (Combo1.AddItem):
sql = "Select * from SysObjects Where Name like '%" & cboEngMake.Text & "%'"
rs.Open sql, cn, adOpenKeyset, adLockOptimistic
If Not rs.EOF And Not rs.BOF Then
rs.MoveFirst
Item = rs.Fields("Name".Value
'MsgBox (Item)
Model = Mid(Item, 15, 9)
With cboEngModel
Do Until rs.EOF = True
If cboEngModel.Text <> Model Then
cboEngModel.AddItem Model
rs.MoveNext
ElseIf cboEngModel.Text = Model Then
rs.MoveNext
End If
Loop
End With
End If
It still adds all of the models as many times as they appear.(The model variable comes from trimming the table name as above) How do I code it to just add an item only one time even though the recordset will return more than one distinct value. The sql "Distinct" keyword will not help since the tables have similar names with just the end of the table name different. Any help is greatly appreciated.
Rob
Just my $.02.
sql = "Select * from SysObjects Where Name like '%" & cboEngMake.Text & "%'"
rs.Open sql, cn, adOpenKeyset, adLockOptimistic
If Not rs.EOF And Not rs.BOF Then
rs.MoveFirst
Item = rs.Fields("Name".Value
'MsgBox (Item)
Model = Mid(Item, 15, 9)
With cboEngModel
Do Until rs.EOF = True
If cboEngModel.Text <> Model Then
cboEngModel.AddItem Model
rs.MoveNext
ElseIf cboEngModel.Text = Model Then
rs.MoveNext
End If
Loop
End With
End If
It still adds all of the models as many times as they appear.(The model variable comes from trimming the table name as above) How do I code it to just add an item only one time even though the recordset will return more than one distinct value. The sql "Distinct" keyword will not help since the tables have similar names with just the end of the table name different. Any help is greatly appreciated.
Rob
Just my $.02.