In my Access 2013 application, I am using an array to temporarily store a small amount of data I want super quick access to later.
There may be zero to many items matching the criterion to be added to the array.
As long as some items are loaded into the array the below logic works fine. However, when there are no items added to the array I get a subscript out of of range error when evaluating the UBound of the array.
How do I check for this possibility that there were no items added to the array?
I am trying
ay) Then but that statement doesn't evaluate to 'True' if there are no entries in the array.
In the module loading and unloading the arrays I am setting "Option Base 1".
The definition of the array:
Dim aRecipientsArray() As Long
The routine to load the array:
Private Sub loadRecipientArray()
Dim wkArrayIndex As Long
wkArrayIndex = 0
Dim rs As DAO.Recordset
Set rs = Me![frmDocumentInterestedParties_Sub].Form.RecordsetClone
If rs.RecordCount > 0 Then
While Not rs.EOF
wkArrayIndex = wkArrayIndex + 1
ReDim Preserve aRecipientsArray(wkArrayIndex) As Long
aRecipientsArray(wkArrayIndex) = Nz(rs!InterestedPartyTypeID)
Set rs = Nothing
The routine to unload the array:
Private Sub displayRecipientArray()
Dim recsRead As Long
if isNull(aRecipientsArray) then
MsgBox "Array is empty)
For recsRead = 1 To UBound(aRecipientsArray)
Debug.Print " "
Debug.Print recsRead, _