Results 1 to 4 of 4

Thread: 1st time user of arrays

  1. #1

    Thread Starter
    New Member
    Join Date
    Jul 2001
    Location
    Colorado
    Posts
    1

    Question 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

  2. #2
    Fanatic Member Psyrus's Avatar
    Join Date
    Jul 2000
    Location
    NJ
    Posts
    602
    Have you tried removing the Do While True Loop? What is this accomplishing?


    Chris
    Chris

    VB 6.0 Calendar App Video Gamers Group
    Don't forget to rate people if they helped you.

  3. #3
    Fanatic Member Gaffer's Avatar
    Join Date
    Nov 2000
    Location
    London
    Posts
    828
    Mmm, yeah, Do While what is True?

  4. #4
    Dazed Member
    Join Date
    Oct 1999
    Location
    Ridgefield Park, NJ
    Posts
    3,418
    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
  •  



Click Here to Expand Forum to Full Width