I'm new in VBA access, what I want to do is put data from a table to a collection, but when I do it and check the collection all the rows have the data from the last row I load.
Public Function projectStart() As Collection
Dim cn As New ADODB.connection
Dim rs As New ADODB.Recordset
Set cn = CurrentProject.connection
Dim sqlQuery As String
Set projectStart = New Collection
sqlQuery = "select * from p6projects"
rs.Open sqlQuery, cn
Do Until rs.EOF
Dim cashFlow As New cashFlow
cashFlow.letIdproject = rs!id
cashFlow.letStartDate = rs!startDate
cashFlow.letBlstartdate = rs!blStartDate
projectStart.Add cashFlow
rs.MoveNext
Loop
rs.Close
Set rs = Nothing
cn.Close
Set cn = Nothing
End Function
I'm loading 10 rows from a table, when I print them shows me this, the same data in any rows.
10 2/6/2019 2/6/2019
10 2/6/2019 2/6/2019
10 2/6/2019 2/6/2019
10 2/6/2019 2/6/2019
10 2/6/2019 2/6/2019
10 2/6/2019 2/6/2019
10 2/6/2019 2/6/2019
10 2/6/2019 2/6/2019
10 2/6/2019 2/6/2019
10 2/6/2019 2/6/2019