Hello Olaf. :-)
>Hello Olaf. :-)
>
[quoted text clipped - 65 lines]
>>
>>Olaf
I've decided to go about this in a different way.
From a For..Loop 0 to 39, I'll grab a single columns worth of data to
fill the grid row 1 to 15. This appears to work just fine.
:-)
Webbiz
Schmidt - 04 Jul 2009 22:27 GMT
> I've decided to go about this in a different way.
>
> From a For..Loop 0 to 39, I'll grab a single columns worth of
> data to fill the grid row 1 to 15. This appears to work just fine.
Ok - that would also be an approach, to "transpose" all that -
probably does not make that much difference - if you do it
15 times, delivering 40 "Column"-Values - or if you're doing
it 40 times, delivering 15 "Row" values - maybe the overhead
in my posted routine is a bit smaller, since it is "asking" the
DB-engine only 15 times about a properly filled up (with
40 entries) recordset.
With your approach you will request the engine 40 times,
to deliver a 15-entry-recordset - but in that range it is really
not that important, which way you go at it - you'd probably
see a difference, if we'd talk about 1500 on 4000 (or
the other way round 4000 on 1500) - but with such a small
"result-matrix" it is really not that important, which way you
prefer.
Olaf
Webbiz - 05 Jul 2009 04:47 GMT
>> I've decided to go about this in a different way.
>>
[quoted text clipped - 17 lines]
>
>Olaf
It's hard to get around the speed thing when you have to fill up those
grid rows. If all I needed to do was to add up the values, than it
would be a completely different thing altogether.
:-)
> >Then just reduce your above query to what you really want
> >(the starting dates) in a first step:
[quoted text clipped - 16 lines]
>
> Thanks, but this isn't what I'm trying to do.
Ok, let's see...;-)
> The only need I have of the 15 returned records is to
> get the dates themselves, as each date
> represents the start of each 40 record datasets.
Yes, that's what is done in the routine above.
> By using these 15 dates, I need to search the data, find the date,
> then read in 40 records (including the record of that date).
> I need to do this for all 15 dates.
And that's exactly what the routine above ensures - it
is calling the soub-routine below 15 times then.
Private Sub AddColumns(sDate As String, SumArr())
Dim RsCols as cRecordset, i As Long
SQL = "SELECT Point FROM dtaTable WHERE Date >= '" & _
sDate & "' ORDER BY Date LIMIT 40"
Set RsCols = Cnn.OpenRecordset(SQL)
For i = 0 to RsCols.RecordCount - 1
SumArr(i) = SumArr(i) + RsCols.ValueMatrix(i, 0)
Next i
End Sub
In each of these 15 rounds the above routine delivers
your "40 following entries", using your starting-
Date (passed as a parameter) - and including the
data for this starting date as the first of the 40 entries
too.
> Each of these 15 datasets of 40 records will be plotted on
> a Grid, ...
In the routine above I just cumulated the 15*40 values
in an appropriate ColumnSum-Array - but enhancing
the very same loop (which currently only ensures the up-
suming), to additionally fill in a grid of 15x40-layout -
or to render these points-data "live" is no problem IMO.
> I need this for DISPLAY purposes.
No problem, as said.
> Once completed, I can then simply add up these columns
> on a new row below these 15, just a like a spreadsheet.
It's up to you, what you do within the loop then - and into
what array you fill in your 15x40 entries we achieve with the
construct above. In my example I've only used the Sum-
"vector" for the final results of your (0 to 39) column-sums -
but you can of course also put your values not (only) into an
vector-like-array, but into a properly dimensioned one
(0 to 14, 0 to 39) - and do your upsuming later on on that
larger array (rendering your values beforehand in your GUI
from that larger array).
> If possible to do all at once, I would suppose that it would
> then be a matter of just looping through 1 recordset once
> only, skipping to the next row of the Grid after each read
> in of 40 records.
It would also be possible, to define a really large SQL-String
for that - and deliver all your data at once - but the code to
create that large SQL-String would need more lines of code
than the solution that works with these separated calls (as shown).
Olaf
Webbiz - 05 Jul 2009 05:03 GMT
>> >Then just reduce your above query to what you really want
>> >(the starting dates) in a first step:
[quoted text clipped - 14 lines]
>> > 'SumArr now contains what you wanted to achieve IMO
>> >End Sub
What threw me off was the 'column sums" and "SumArr" wording. Since
the task is mostly to fill a 15 x 40 grid more than it is to 'sum' up
anything, I assumed it wasn't geared to what I wanted to do.
>Private Sub AddColumns(sDate As String, SumArr())
>Dim RsCols as cRecordset, i As Long
[quoted text clipped - 6 lines]
> Next i
>End Sub
>> If possible to do all at once, I would suppose that it would
>> then be a matter of just looping through 1 recordset once
[quoted text clipped - 6 lines]
>
>Olaf
You're right. I seemed to miss the rest of the code somehow. Good
thing it wasn't a snake it would have bit my face. :-0
The above is a better fit for filling up the 15 x 40. However, I came
to find out that some of my 40 date sets are not 'apples to apples'
for comparison, and so doing the one-column at a time turned out to be
what I needed as it will skip over a set if there isn't a match in one
or more of the sets. Anyway, don't fret the details as it gets into my
algorithm...
Thanks a bunch. I'm learning. :-)
Webbiz