Hello,
I want to do something fairly simple (I think) and populate a listview box on an access form with a selection of records from a single table. I thought the most sensible way to do this (other than some sort of convoluted loop involving multiple DLookup's) would be to return a recordset and then loop through that somehow.
I think I've figured out how to return the recordset;
(not sure if I need to assign the recordset to the form?)
However, I can't figure out how to loop through the recordset and pull out the data I want. What I want to do is something like;
...but that code's all just made up and recordsets, it seems, just don't work this way. The problem is that all the help files and guides I've found regarding recordset objects are either very vague or deal with far more complicated things I just don't want to do
...so, sorry that this is rather taking advantage of everybody's good nature here, but can anybody suggest a way I can do what I want to do? Alternatively, can anybody explain the basics of how to use recordset objects (or point me to a tutorial which is easy to follow?)
Thanks,
Paul
I want to do something fairly simple (I think) and populate a listview box on an access form with a selection of records from a single table. I thought the most sensible way to do this (other than some sort of convoluted loop involving multiple DLookup's) would be to return a recordset and then loop through that somehow.
I think I've figured out how to return the recordset;
Code:
Set rstHistory = New ADODB.Recordset
rstHistory.CursorLocation = adUseClient
rstHistory.Open "Select updateDate, updateSource, updateDescription FROM History WHERE reqID = " & txtReqID.Value, _
CurrentProject.Connection, adOpenKeyset, adLockOptimistic
Set Forms("Requirements_New").Recordset = rstHistory
(not sure if I need to assign the recordset to the form?)
However, I can't figure out how to loop through the recordset and pull out the data I want. What I want to do is something like;
Code:
For Each objRecord in rstHistory
strListItem = objRecord.FieldData(0) & ","
strListItem = strListItem & objRecord.FieldData(1) & ","
strListItem = strListItem & objRecord.FieldData(2)
Listview.AddItem strListItem
Next
...but that code's all just made up and recordsets, it seems, just don't work this way. The problem is that all the help files and guides I've found regarding recordset objects are either very vague or deal with far more complicated things I just don't want to do
...so, sorry that this is rather taking advantage of everybody's good nature here, but can anybody suggest a way I can do what I want to do? Alternatively, can anybody explain the basics of how to use recordset objects (or point me to a tutorial which is easy to follow?)
Thanks,
Paul