Hi,
I'm using the getrows recordset method to load a variant array but the not all records are loaded. The recordcount is correct but the UBound value is way to small. In all the attempts I've tried I have noticed it did work occasionally. It makes me wonder if I have some resource problem even though the number of records is only 58 with 9 fields.
Any ideas anyone?
Cheers
Private Sub cmdGo_Click()
Dim strSqlQuery As String
Dim strAdd As String
Dim intRecCount As Integer
Dim intArrayClear As Integer
Dim intNumberRows As Integer
Dim intNumberFields As Integer
Dim intRowCnt As Integer
Dim intFieldCnt As Integer
Dim qdf As DAO.QueryDef
Dim strResultArray As Variant
Dim strTransResultArray As Variant
' Clear results box
If Me![lstResult].ListCount <> 0 Then
For intArrayClear = 0 To Me![lstResult].ListCount - 1
Me![lstResult].RemoveItem 0
Next
End If
strResultArray = Empty
Set myDb = CurrentDb()
Set rs = Nothing
Set qdf = myDb.QueryDefs("qryAssetDetails")
qdf.Parameters(0) = Me.cboChannel
Set rs = qdf.OpenRecordset(dbOpenDynaset, dbReadOnly)
' Sometimes required to get accurate count
rs.MoveLast
rs.MoveFirst
intRecCount = rs.RecordCount
Debug.Print intRecCount
strResultArray = rs.GetRows(rs.RecordCount)
Debug.Print UBound(strResultArray, 1)
Debug.Print UBound(strResultArray, 2)
I'm using the getrows recordset method to load a variant array but the not all records are loaded. The recordcount is correct but the UBound value is way to small. In all the attempts I've tried I have noticed it did work occasionally. It makes me wonder if I have some resource problem even though the number of records is only 58 with 9 fields.
Any ideas anyone?
Cheers
Private Sub cmdGo_Click()
Dim strSqlQuery As String
Dim strAdd As String
Dim intRecCount As Integer
Dim intArrayClear As Integer
Dim intNumberRows As Integer
Dim intNumberFields As Integer
Dim intRowCnt As Integer
Dim intFieldCnt As Integer
Dim qdf As DAO.QueryDef
Dim strResultArray As Variant
Dim strTransResultArray As Variant
' Clear results box
If Me![lstResult].ListCount <> 0 Then
For intArrayClear = 0 To Me![lstResult].ListCount - 1
Me![lstResult].RemoveItem 0
Next
End If
strResultArray = Empty
Set myDb = CurrentDb()
Set rs = Nothing
Set qdf = myDb.QueryDefs("qryAssetDetails")
qdf.Parameters(0) = Me.cboChannel
Set rs = qdf.OpenRecordset(dbOpenDynaset, dbReadOnly)
' Sometimes required to get accurate count
rs.MoveLast
rs.MoveFirst
intRecCount = rs.RecordCount
Debug.Print intRecCount
strResultArray = rs.GetRows(rs.RecordCount)
Debug.Print UBound(strResultArray, 1)
Debug.Print UBound(strResultArray, 2)