I am trying to transfer a field from an access table to an array. This is the code I have and it looks correct but I am getting a Type Mismatch error:
Public Function GetFieldToArray() As Variant
Dim rst As DAO.Recordset: Set rst = CurrentDb.OpenRecordset("SELECT 'Account ID' FROM Lookup")
rst.MoveLast
rst.MoveFirst
GetFieldToArray = rst.GetRows(rst.RecordCount)
End Function
and here is where I am calling the function:
Dim pk As Variant: Set pk = GetFieldToArray()
What am I missing?
[ ]
instead of apostrophes to define object names (fields, controls, tables, queries, forms, reports) in query. Or better, don't use spaces nor punctuation/special characters nor reserved words in naming convention and[ ]
should not be needed.