Re: Arrays in Access.
- From: "Larry Linson" <bouncer@xxxxxxxxxxxxx>
- Date: Thu, 15 Dec 2005 16:51:48 GMT
The real question, Randy, would be "What is the compelling reason for moving
the results of a query into an array?" That is something that a procedural
programmer would do as a matter of course, but not necessarily a good
approach in a database application. It took many of us some time to change
our view from the procedural programming approach to "The Access Way", but
once we get accustomed to "The Access Way", database applications become
much easier.
I can think of several approaches to retrieving the Max and Min... a totals
query, the DMAX and DMIN functions, for example... in addition to the ways
already mentioned. And all a LOT easier than filling and sorting an array
(and likely as fast, or faster, to execute).
Larry Linson
Microsoft Access MVP
"Randy Harris" <randy@xxxxxxxxxxxx> wrote in message
news:3R%nf.41541$6e1.13625@xxxxxxxxxxxxxxxxxxxxxxxxxxxxx
>
> "Steve" <theonesteve@xxxxxxxxx> wrote in message
> news:1134590993.741788.232710@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
>> pietlin makes a good point. If you don't order the SQL query, you'll
>> need to a) sort your array (bubble sort would be efficient, since it's
>> only 20 elements), or b) write your array to a temporary table and run
>> a query off of the temporary table (which begs the question of "why
>> didn't you just sort the original query to start with?")
>>
>> If your situation is different than I am understanding it to be, can
>> you show how your array gets its values from the SQL query? I.e., does
>> the SQL query feed into a form, and your array pick out data from the
>> form?
>>
>
>
> It looks like pietlin has the OP on track by sorting the data. In case
> that
> doesn't work for him, however, I wanted to take exception to this
> alternative. Since he only needs the min and max values from the array,
> he
> really doesn't need to sort it. It would be more efficient and easier to
> code to simply make a single pass through the array doing comparisons.
>
> psuedocode:
>
> minval = a(lbound)
> maxval = a(lbound)
> for i = lbound + 1 to ubound
> if minval < a(i) then minval = a(i)
> if maxval > a(i) then maxval = a(i)
> next i
>
> --
> Randy Harris
> I'm pretty sure I know everything that I can remember.
>
.
- References:
- Arrays in Access.
- From: KK
- Re: Arrays in Access.
- From: pietlinden
- Re: Arrays in Access.
- From: KK
- Re: Arrays in Access.
- From: Steve
- Re: Arrays in Access.
- From: Randy Harris
- Arrays in Access.
- Prev by Date: Re: The data has been changed. Another user edited this record and saved the changes before you attempted to save your changes. Re-edit the record
- Next by Date: Re: Ouch! that's a long subject line
- Previous by thread: Re: Arrays in Access.
- Next by thread: Re: Arrays in Access.
- Index(es):
Relevant Pages
|
|