This question should apply to any VBA situ with events:
I've filled an array within a Form_Load() event in MS Access. Now I would like to extract, dereference, the contents of that array from within a ListBox_DblClick() event.
I Dim'd the array at the top of the form module (if it was Excel, it would be a sheet module) they both share; no luck in having the ListBox_DblClick event recognize that there is an array anywhere.
Thanks for any help:
Dim ArrWhatever() As String
Function ThisArr(tmpVal1, tmpVal2, tmpVal3)
Dim numOfCols As Long
Dim I, J, x As Long
If Len(tmpVal1) > 0 Then
ReDim Preserve ArrWhatever(numOfCols, 1 To J)
Arr(1, J) = tmpVal1
Arr(1, J) = tmpVal2
Arr(1, J) = tmpVal3
J = J + 1
End If
End Function
Form_Load()
...
retVal = ThisArr(val1, val2, val3)
End Sub
If the contents are subsequently extracted by using
For x = LBound(Arr, 2) To UBound(Arr, 2)
Debug.Print ArrWhatever(1, x) & " " & ArrWhatever(2, x) & " " & ArrWhatever(3, x)
Next
from inside the Form_Load event, then everything is found.
But so far no luck in getting a different event adjacent on the same form to recognize the array.