I'm using VB6. Trying to fill 3 comboboxes with distinct values from a database. I'm using the following code:
'\\\\\\\\\\\\\
Dim db1 As DAO.Database
Dim rst1 As DAO.Recordset
SQL = "SELECT DISTINCT invoicenum, boat, workdate FROM timesheet"
Set db1 = DBEngine.OpenDatabase("c:\bclub\boatclubData32.mdb")
'Open the Recordset
Set rst1 = db1.OpenRecordset(SQL, dbOpenSnapshot)
rst1.MoveFirst
While Not rst1.EOF
Combo5.AddItem rst1!invoicenum
Combo6.AddItem rst1!boat
Combo7.AddItem rst1!workdate
rst1.MoveNext
Wend
'\\\\\\\\\\\\
My question is; When I eliminate the 3dr item(combo7.addItem) combo5 and combo6 fill with no duplicates. But when I add combo7 and change my SQL by adding "workdate" the boxes fill, but with dupilcates as well. Why?????
Thanks for any help!
'\\\\\\\\\\\\\
Dim db1 As DAO.Database
Dim rst1 As DAO.Recordset
SQL = "SELECT DISTINCT invoicenum, boat, workdate FROM timesheet"
Set db1 = DBEngine.OpenDatabase("c:\bclub\boatclubData32.mdb")
'Open the Recordset
Set rst1 = db1.OpenRecordset(SQL, dbOpenSnapshot)
rst1.MoveFirst
While Not rst1.EOF
Combo5.AddItem rst1!invoicenum
Combo6.AddItem rst1!boat
Combo7.AddItem rst1!workdate
rst1.MoveNext
Wend
'\\\\\\\\\\\\
My question is; When I eliminate the 3dr item(combo7.addItem) combo5 and combo6 fill with no duplicates. But when I add combo7 and change my SQL by adding "workdate" the boxes fill, but with dupilcates as well. Why?????
Thanks for any help!