Re: Arrays in Access.



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.
>


.



Relevant Pages

  • Re: Mix/Max/Avg Help based on dynamic ranges
    ... Did you enter Biff's formula as an array? ... The query I gave you is dependent on your breaking out the ranges as Biff ... Where Nums are the values to avg based on the head count range. ... deemed optimal for building device profiles based on locn size and device ...
    (microsoft.public.excel.worksheet.functions)
  • Re: Imitating Mail Merge on server
    ... given moment we know which data (in this case, customers) is being worked ... and concantenate each query together. ... loop the array, plug in the current recordset value. ... We have close to fifty tokens that we use in the application correspondence, ...
    (microsoft.public.inetserver.asp.general)
  • Re: Multidimensional Array Question
    ... I am sorting the data in the query from each table eg. ... Now to sort() it ... ... Can I sort a multidimensional array? ... Keep your sort on the server by adding the ORDER BY clause to you SQL ...
    (alt.php)
  • Re: Subquery Confusion
    ... Then I got this crazy idea that an Array can only contain a maximum ... number of characters, ... Then I decide that maybe I'm completely wrong with my query, ... it out of Excel VBA and spit it into Microsoft SQL Server Management ...
    (microsoft.public.excel.programming)
  • Re: Form fields array
    ... I see your point about the array being empty.. ... Dim incDays ... for counter=0 to iDays 'iDays are the count of how many days between ... >> not know how many records the query will pull up. ...
    (microsoft.public.inetserver.asp.db)