G
GeorgeAtkins
Help!
(I am using Access 2003.)
I am having problems passing a 2-dimensional array to a subroutine. The
array is "redimed", as the number of elements is not known. The array fills
successfully, as my debug.print statement shows:
x=4: 84111 13
x=5: 87315 1
x=6: 87326 3
However, when the array is passed to another routine, the program crashes
with an error when it tries to read the passed array: "Compile Error:
Expected Array"
I've tried different syntaxes, but nothing seems to work.
The subroutine opens an OLE Automation session with Excel.
This goes just fine. I can even push in single variable data just fine.
But Access chokes on my array. Here is a code snippet of both routines:
Sub CallingRoutine
Dim arWU() As Long
....
ReDim Preserve arWU(1, RecRows)
For x = 0 To RecRows - 1
arWU(0, x) = rsWrk.Fields("CrsSection") ' a long
arWU(1, x) = Nz(rsWrk.Fields("CurrWorkHrs"), 0) ' a long
' I already showed you sample outputs of the debug statement
Debug.Print "x=" & x & ": " & arWU(0, x) & " " & arWU(1, x)
.MoveNext
Next x
UpdateExcelSumAttd, SumMbr, arWU(1, RecRows)
....
End Sub
Sub UpdateExcel(att As Single, mbr As Single, ByRef WUnits As Long)
Dim y As Integer
....
Set oExcel = CreateObject("Excel.Application")
oExcel.Workbooks.Open "H:\SDL Tracking Sheets\Student.xls"
oExcel.Range("B15").Select
For y = 0 To arMax - 1
oxcel.activecell.Offset(y, 5) = WUnits(1, y) ' <-- BOMBS on WUNits word
Next y
....
If I replace "WUnits(1,y)" with a literal value, the routine works just
fine. it also works fine with a single variable. Any help is gratefully
appreciated!!
(I am using Access 2003.)
I am having problems passing a 2-dimensional array to a subroutine. The
array is "redimed", as the number of elements is not known. The array fills
successfully, as my debug.print statement shows:
x=4: 84111 13
x=5: 87315 1
x=6: 87326 3
However, when the array is passed to another routine, the program crashes
with an error when it tries to read the passed array: "Compile Error:
Expected Array"
I've tried different syntaxes, but nothing seems to work.
The subroutine opens an OLE Automation session with Excel.
This goes just fine. I can even push in single variable data just fine.
But Access chokes on my array. Here is a code snippet of both routines:
Sub CallingRoutine
Dim arWU() As Long
....
ReDim Preserve arWU(1, RecRows)
For x = 0 To RecRows - 1
arWU(0, x) = rsWrk.Fields("CrsSection") ' a long
arWU(1, x) = Nz(rsWrk.Fields("CurrWorkHrs"), 0) ' a long
' I already showed you sample outputs of the debug statement
Debug.Print "x=" & x & ": " & arWU(0, x) & " " & arWU(1, x)
.MoveNext
Next x
UpdateExcelSumAttd, SumMbr, arWU(1, RecRows)
....
End Sub
Sub UpdateExcel(att As Single, mbr As Single, ByRef WUnits As Long)
Dim y As Integer
....
Set oExcel = CreateObject("Excel.Application")
oExcel.Workbooks.Open "H:\SDL Tracking Sheets\Student.xls"
oExcel.Range("B15").Select
For y = 0 To arMax - 1
oxcel.activecell.Offset(y, 5) = WUnits(1, y) ' <-- BOMBS on WUNits word
Next y
....
If I replace "WUnits(1,y)" with a literal value, the routine works just
fine. it also works fine with a single variable. Any help is gratefully
appreciated!!