Hey Guys
Well I'm really frustrated with this, despite having tried numerous different methods, I still can't simply add data to specific columns within my combo box. I'm looping through a recordset to do this, my code is awful, simply because I couldn't figure how to write those two queries as one, therefore I'm having to do the same operation twice.
Basically I would like rs![ResourceCode] to fill column (0) and rs![Description to fill column (1).
Help appreciated.
Well I'm really frustrated with this, despite having tried numerous different methods, I still can't simply add data to specific columns within my combo box. I'm looping through a recordset to do this, my code is awful, simply because I couldn't figure how to write those two queries as one, therefore I'm having to do the same operation twice.
Basically I would like rs![ResourceCode] to fill column (0) and rs![Description to fill column (1).
Help appreciated.
Code:
Private Sub cboresourcetype_AfterUpdate()
Dim sqlQuery(1) As String, countRecords As Integer, llistIndex As Long, rs As Object
sqlQuery(0) = "SELECT Description, ResourceCode FROM TblResource WHERE ResourceType = '" & cboresourcetype & "' AND New = 'Yes'"
sqlQuery(1) = "SELECT R.Description, R.ResourceCode FROM TblResource AS R LEFT JOIN TblRsrcEmp AS RSE ON R.ResourceCode = RSE.ResourceCode WHERE R.ResourceType = '" & cboresourcetype & "' AND RSE.Returned = 'Yes'"
Set rs = CurrentDb.OpenRecordset(sqlQuery(0))
'testing if there's a record in there
If rs.EOF = False Then
With Me.cboresources
Do
'' doesn't work .Column(0).AddItem = rs![ResourceCode]
.AddItem rs![ResourceCode]
.AddItem rs![Description]
rs.MoveNext
Loop Until rs.EOF
End With
rs.Close
Set rs = Nothing
End If
Set rs = CurrentDb.OpenRecordset(sqlQuery(1))
If rs.EOF = False Then
With Me.cboresources
Do
.AddItem rs![ResourceCode]
.AddItem rs![Description]
rs.MoveNext
Loop Until rs.EOF
End With
rs.Close
Set rs = Nothing
End If
End Sub