Re: I need a scredriver, and all I have are hammers...
- From: "Chris2" <rainofsteel.NOTVALID@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Sun, 4 Dec 2005 03:44:40 -0800
<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.
.
- References:
- I need a scredriver, and all I have are hammers...
- From: sgbotsford
- I need a scredriver, and all I have are hammers...
- Prev by Date: Append & Sub Queries
- Next by Date: Queries with param
- Previous by thread: I need a scredriver, and all I have are hammers...
- Next by thread: Re: I need a scredriver, and all I have are hammers...
- Index(es):
Relevant Pages
|