N
Niklas Östergren
Hi!
I have nevere used array´s before and have read a little about them and are
now trying to populate an one dimensional array with a primary key from a
local table. But i keep getting error (Runtime Error 13) even if I dim the
array as a variant (please se my code below).
Anyone knowing what I´m doing wrong here?
TIA!
// Niklas
=============================================
Public Function ArrayExample()
Dim rec As DAO.Recordset
Dim lngarrPersonID() As Long
Set rec = Currentdb().OpenRecordset("tblPerson", dbOpenSnapshot)
rec.MoveLast
ReDim lngarrPersonID(rec.RecordCount)
rec.MoveFirst
Do While Not rec.EOF
lngarrPersonID = rec!PersonID
Debug.Print lngarrPersonID(0)
rec.MoveNext
Loop
Erase lngarrPersonID
rec.Close
Set rec = Nothing
End Function
====================================================
I have nevere used array´s before and have read a little about them and are
now trying to populate an one dimensional array with a primary key from a
local table. But i keep getting error (Runtime Error 13) even if I dim the
array as a variant (please se my code below).
Anyone knowing what I´m doing wrong here?
TIA!
// Niklas
=============================================
Public Function ArrayExample()
Dim rec As DAO.Recordset
Dim lngarrPersonID() As Long
Set rec = Currentdb().OpenRecordset("tblPerson", dbOpenSnapshot)
rec.MoveLast
ReDim lngarrPersonID(rec.RecordCount)
rec.MoveFirst
Do While Not rec.EOF
lngarrPersonID = rec!PersonID
Debug.Print lngarrPersonID(0)
rec.MoveNext
Loop
Erase lngarrPersonID
rec.Close
Set rec = Nothing
End Function
====================================================