Hi all,
I want to populate 2 combo box's with SQL query'd values, so i do it like so
Code
'***************************************************************************' '
' Functions To Populate Data to search combo boxs '
'***************************************************************************'
Option Explicit
Public rsComb As ADODB.Recordset
Public Function SelectCombVal(ByRef rsComb)
On Error GoTo errorhandler
Dim sSelect As String
Set rsComb = New ADODB.Recordset
bNoBreaks = False
sBreakName$ = frmLogin.cmbUserID
sSelect = "' AND [COMPLETED] = 0) ORDER BY [DEPOT]"
Select Case sBreakName$
Case sBreakName$
rsComb.Open "SELECT [DEPOT],[STOCK],[COMPLETED],[TIME_FLAG] FROM tblBreaks WHERE ([ALLOCATED_TO] = '" & sBreakName$ & sSelect, cn, adOpenKeyset, adLockOptimistic
End Select
Do While Not rsComb.EOF
frmAgent.txtDepotSearch.AddItem rsComb!DEPOT
frmAgent.txtStockSearch.AddItem rsComb!STOCK
rsComb.MoveNext
Loop
Exit Function
errorhandler:
MsgBox Err.Description, vbCritical, "Contact Software Developer!!"
End Function
Display More
BUT...........
Even though this works a treat, the combo box display all the duplicates aswell.
e.g. [DEPOT] D,D,D,D,HHI,HHU,HHH,HHH,HHH,I,I,E,R,R,E
I want
e.g. [DEPOT] D,HHI,HHU,HHH,I,E,R
e.g [STOCK] sdf6546,asd456,zxc123,lpo456,sdf6546,asd456,zxc123,lpo456
I Want
e.g [STOCK] sdf6546,asd456,zxc123,lpo456
I've tried putting the DISTINCT after the SELECT but this wont work because i need to DISTINCT it AFTER i've query'd the recordset, otjherwise i wont get the results from the SQL staement i need.
Does anyone know how to re-order this or add something to get the results
Thanks
Error#9