G
Guest
I am trying to setup an array to store a single value from multiple record
sets. The value is Margin. Here is the code I have:
Option Compare Database
Option Explicit
Dim ValI As Double
Dim ValArr As Variant
Private Sub FillArray()
ValI = 0
While Not Recordset.EOF
ValArr(ValI) = Margin
Recordset.MoveNext
Wend
End Sub
Private Sub PrintArray()
ValI = 0
For ValI = 0 To UBound(ValArr())
Debug.Print " "; ValArr(ValI)
Next ValI
End Sub
I have a Tabular form setup that reads data via a query and populates the
form. So the first line would be recordset 1, the second line is recordset 2,
and so on. What I am attempting to do is store the values of 'Margin' into an
array to be used later in some calculations. I have the FillArray procedure,
and PrintArray procedure setup on a couple buttons at the bottom of the form
so I can control when it does either (later to be moved to be called from the
form load). Every time I press the Fill Array button I get a type mismatch
error (runtime error 13), and have tried to correct it with no success.
Probably something simple I am overlooking. I could really use some help on
this. Thanks in advance for any and all answers / help.
C_Ascheman
sets. The value is Margin. Here is the code I have:
Option Compare Database
Option Explicit
Dim ValI As Double
Dim ValArr As Variant
Private Sub FillArray()
ValI = 0
While Not Recordset.EOF
ValArr(ValI) = Margin
Recordset.MoveNext
Wend
End Sub
Private Sub PrintArray()
ValI = 0
For ValI = 0 To UBound(ValArr())
Debug.Print " "; ValArr(ValI)
Next ValI
End Sub
I have a Tabular form setup that reads data via a query and populates the
form. So the first line would be recordset 1, the second line is recordset 2,
and so on. What I am attempting to do is store the values of 'Margin' into an
array to be used later in some calculations. I have the FillArray procedure,
and PrintArray procedure setup on a couple buttons at the bottom of the form
so I can control when it does either (later to be moved to be called from the
form load). Every time I press the Fill Array button I get a type mismatch
error (runtime error 13), and have tried to correct it with no success.
Probably something simple I am overlooking. I could really use some help on
this. Thanks in advance for any and all answers / help.
C_Ascheman