Re: I need a scredriver, and all I have are hammers...




<sgbotsford@xxxxxxxxx> wrote in message
news:1133674002.318313.112940@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
> I'm starting to have a real appreciation for access, but I'll
admit
> there are some frustrations. I'm trying to figure out how to
repeat a
> similar action without having to create and save dozens of similar
> queries.
>
> I have a small database with a thousand locations in it. Each
location
> has GPS coordinates. Each location is assigned a zone.
>
> For use with the GPS, I want to write out each zone as a text file
in
> suitable format for my mapping program. At this point the only
way
> I've been able to figure out how to do this is to write a bunch of
> querries.
>
> Querry_A
> Create a querry, where Zone is like "A"
>
> Querry_B
> Create a querry where zone is like "B"
>
> ...
>
> Then create a macro that uses TransferText for each query. This
is
> tedious.
>
> How do I create a loop construct? In psuedo code what I want to
do is
> this:
>
> foreach zone (A..Z) {
> Select from Table GPS where GPS!Zone = $Zone output to table
temp
> TransferText temp , comma_delimited, $Zone.txt
> TransferText temp, excel, $Zone.xls
> }

sgbotsford,

Looping:

Do Until <condition>
<code to repeat>
Loop

Exam:

With rs
.MoveFirst
Do Until .Eof
strFileName = .Fields("Zone") & _
".xls"
<TransferText Code using strFileName as a parameter, etc.>
.MoveNext
Loop

End With

Also:

Do While <condition>
<code to repeat>
Loop

For <variable> = <literal | variable> to <literal | variable>
<code to repeat>
Next

That's the basics. There is also While/Wend, and putting the
Until|While of Do after Loop instead of after Do.

ForEach is for iterating over object collections. You could do this
if you wanted to, but it would involve creating a class,
instantiating an object, loading the object with the zones or
locations as mentioned above, and then iterating over that, etc.

For your purposes, you'll use string assembly to make new output
file names as each iteration of the loop repeats (in a manner
similar to what the example above shows).


Sincerely,

Chris O.


.



Relevant Pages

  • Re: Vsita 15P programming question
    ... exactly you're not gonna see a trouble for part of the loop until the switch ... open circuit switches with eolr where it belongs... ... At that time it will either continue to "show zone" open ...
    (alt.security.alarms)
  • Re: Omaha shooter
    ... # THIS HAPPENED IN A "Gun Free" Zone!!! ... That is all you have to repeat. ... If you want to get things rolling please make yourself an accout ...
    (rec.guns)
  • I need a scredriver, and all I have are hammers...
    ... has GPS coordinates. ... Each location is assigned a zone. ... TransferText temp, comma_delimited, $Zone.txt ... I want different fields for the excel ...
    (microsoft.public.access.queries)
  • Re: Boiler Hookup circulators
    ... super store on the water tank. ... that passes by each zone and then returns to the boiler. ... from the "loop" but that the circulator on the loop is always on heating ...
    (alt.home.repair)
  • Water from closed loop system drains black
    ... Each loop is ... a zone. ... When the water drains out it comes out really dirty. ...
    (alt.home.repair)