That's fine. You need 1 query, and one bit of code.
Assuming you want the files to include the city name as part of the file
name, you'd do something like the following untested air code:
Dim dbCurr As DAO.Database
Dim qdfCurr As DAO.QueryDef
Dim rsCurr As DAO.Recordset
Dim strCity As String
Dim strFile As String
Dim strSQL As String
Set dbCurr = CurrentDb()
Set rsCurr = dbCurr.OpenRecordset("SELECT CityNm FROM Cities")
Do Until rsCurr.EOF = False
strCity = rsCurr!CityNm
strFile = "C:\Output Files\" & strCity & ".txt"
strSQL = "SELECT Field1, Field2, Field3 " & _
"FROM MyTable " & _
"WHERE City = '" & strCity & "'"
Set qdfCurr = dbCurr.QueryDefs("MyCityQuery")
qdfCurr.SQL = strSQL
DoCmd.TransferText acExportDelim, , "MyCItyQuery", strFile
rsCurr.MoveNext
Loop
rsCurr.Close
Set rsCurr = Nothing
Set qdfCurr = Nothing
Set dbCurr = Nothing

Signature
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no private e-mails, please)
> Agreed!
>
[quoted text clipped - 37 lines]
>>>>>>>
>>>>>>> Tough question?
Gary J. Dikkema - 17 Apr 2006 18:35 GMT
THANKS!
> That's fine. You need 1 query, and one bit of code.
>
[quoted text clipped - 71 lines]
>>>>>>>>
>>>>>>>> Tough question?
Gary J. Dikkema - 17 Apr 2006 19:18 GMT
This looks like what I want except I'm not to good with VBA code (and that's
an understatement). <VBG>
So I created a new module and made this a public function and invoke this
from a macro.
I modified the rsCurr statement to point to my file and my field name... as
well as the strSQL...
But nothing happens.
Like I said, VBA is a weak point.
<VBG>
Sorry to ask for what is probably a pretty easy answer...
Thanks again.
> That's fine. You need 1 query, and one bit of code.
>
[quoted text clipped - 71 lines]
>>>>>>>>
>>>>>>>> Tough question?