Hi all,
Usaing Access 2007.
I am trying to lead an array from a recordset using the .GetRows method of the recordset. But my code below returns a Type mismatch error at Debug.Print
What am I doing wrong?
thx
w
Usaing Access 2007.
I am trying to lead an array from a recordset using the .GetRows method of the recordset. But my code below returns a Type mismatch error at Debug.Print
What am I doing wrong?
thx
w
Code:
Option Compare Database
Option Explicit
Option Base 1
Sub GenFiles()
'
'Purpose:
'1.) Clear part Key table
'2.) Update part key table
'3.) Load part keys into an array
'4.) Loop array
'4.) Pass part key to SQL
'5.) Run SQL to query
'6.) Export each query to Excel file
'
'
'Date Developer Action Comments
'---------------------------------------------------------------------------------
'08/03/12 hds Created
'Initialize
DoCmd.SetWarnings False
'Load the part keys into an array
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim intArrayCount As Integer
Dim varrpartKey() As Variant
Dim i, j, k As Long
Dim strTbl As String
strTbl = "tbl_partKeys"
Set db = CurrentDb()
Set rs = db.OpenRecordset(strTbl)
i = rs.RecordCount
j = 1
ReDim varrpartKey(1, 1 To i)
With rs
.MoveFirst
Do Until .EOF
varrpartKey(1, j) = .GetRows
j = j + 1
Loop
.Close
Set rs = Nothing
End With
'Test the array
For k = i To 1 Step -1
Debug.Print varrpartKey(1, k);
Next k
'Tidy up
DoCmd.SetWarnings True
End Sub