With single variable everything works fine, problems appear with dynamic array.
There is a module with global variables:
Option Compare Database
Option Explicit
Global gbl_numberOfPositions As Integer
Global gbl_numberOfDisciplines As Integer
Global gbl_mv_clsJobPostions() As clsJobPostion
Public Sub Init_Globals()
gbl_numberOfPositions = 0
gbl_numberOfDisciplines = 0
ReDim gbl_mv_clsJobPostions(0)
End Sub
In the first form dynamic array is defined
Private Sub Form_Load()
Call Init_Globals
End Sub
Private Sub InitCBox()
Dim rs As DAO.Recordset
Set rs = db.OpenRecordset(strSQL)
rs.MoveLast
ReDim gbl_mv_clsJobPositions(rs.RecordCount)
rs.MoveFirst
i = 1
Do While (Not rs.EOF)
Set gbl_mv_clsJobPositions(i) = New clsJobPostion
gbl_mv_clsJobPositions(i).InitializeMe _
rs![ID Job Position], rs![ID Position], rs![ID Discipline]
i = i + 1
rs.MoveNext
Loop
Debug.Print UBound(gbl_mv_clsJobPositions)
End Sub
Then second one is loaded:
Private Sub Form_Load()
Debug.Print UBound(gbl_mv_clsJobPostions)
End Sub
However two different are returned. In the second case it is zero.
So my question is how to pass dynamic arrays between forms?