|
-
Jul 15th, 2001, 06:33 PM
#1
Thread Starter
New Member
1st time user of arrays
Having an ARRAY problem and data mismatch - one may be causing the other.
This is my first venture into dealing with an array so I may have misinterpreted something in the things I've read.
My goal is simple (I think). I have a query that contains all the info I need to produce some calculations. I need to step through the records in the query and come up with two answers.
Answer one: The sum of a number and a running total based on a field in the query.
Answer two: I need to divide the running total by a set value obtained earlier in the program and store that in an array for later evaluation.
INFO:
[ConcentrationA] is data type TEXT
rawmatTTL is the recordcount of the query
Declarations:
Dim moleCounter as Single
Dim calcResult() as Variant
Dim dpDEGREE as Single
moleCounter = 0
With RstDewPoint
Do While True
For i = 1 To .rawmatTTL
If dpDEGREE <> 0 Then
moleCounter = moleCounter + [ConcentrationA]
ReDim Preserve calcResult(1 To rawmatTTL) As Variant
calcResult(i) = dpDEGREE / moleCounter
End If
.MoveNext
Next i
Exit Do
End With
As a result I am getting an endless loop that virtually locks up Access and I have to force the program closed. It appears to occur at the calcResult (i) section of the code.
So, my first attempt at an array has failed and I need someoen to please pull me from the mire.
Many Thanks
Fred
-
Jul 15th, 2001, 07:10 PM
#2
Fanatic Member
Have you tried removing the Do While True Loop? What is this accomplishing?
Chris
-
Jul 17th, 2001, 06:36 AM
#3
Fanatic Member
Mmm, yeah, Do While what is True?
-
Jul 17th, 2001, 07:49 PM
#4
Dazed Member
Im not quite sure what you are tying to accomplish. If you are using SQL to extract data to be use for subsequent calculations then you are opening a recordset which will contain the SQL data. So all you have to do is step through the recordset itself.
I think the problem is the Do loop.
Dim curRst As New ADODB.Recordset
Dim cnnNet As New ADODB.Connection
Private Sub setinitialconnection()
Dim responce As String
Dim curCat As New ADOX.Catalog
Dim curCmd As New ADODB.Command
cnnNet.Open "Provider = Microsoft.Jet.OLEDB.4.0;Data Source = " & KeySetting
curRst.Open "SELECT * From [Customers]", cnnNet, adOpenKeyset, adLockOptimistic
End Sub
Then you would just step through the record set.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|