Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Modules / DAO / VBA / February 2006

Tip: Looking for answers? Try searching our database.

Creating TXT files based upon a Querry

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
KSL - 21 Feb 2006 10:01 GMT
I'm new to programming Access (and to programming in general) What I'm trying
to do is the following and I'm not exactly sure what is the best way to go
about doing it.

I have a querry that I need to export each record of as a seperate text
file. The text file itself will remain the same (i.e  "foo.txt)" however the
path itself will change based upon 2 fields in the querry
(\\set\path\var1\var2\foo.txt)

Lastly I need the text file to be formatted like so:
blah=var1
blah=var2
blah=var3

Help Suggestions?
Alex Dybenko - 21 Feb 2006 11:34 GMT
Hi,
it is not a complex task, if you are new to programming...
try to look at help samples of opening recordset, looping through it records
and how to output text file (Print # statement) - hope this will give you an
idea how to start

Signature

Alex Dybenko (MVP)
http://alexdyb.blogspot.com
http://www.PointLtd.com

> I'm new to programming Access (and to programming in general) What I'm
> trying
[quoted text clipped - 13 lines]
>
> Help Suggestions?
John Nurick - 21 Feb 2006 16:48 GMT
I usually do this sort of thing with the WriteToFile() function at
http://www.j.nurick.dial.pipex.com/Code/VBA/WriteToFile.htm. Provided
your security settings are not too stringent, you can call WriteToFile()
in a query, using fields or calculated fields as arguments, and it will
create the text files as a side effect of running the query.

For instance, this calculated field:

 Result: WriteToFile([Contents], "C:\Temp\wtf\" & [Filename])

creates a textfile for each record in the query, placing it in the
specified folder, taking the filename from the [Filename] field and the
contents of the file from the [Contents] field.

It's up to you to use calculated fields in the query that format the
text the way you want it.

>I'm new to programming Access (and to programming in general) What I'm trying
>to do is the following and I'm not exactly sure what is the best way to go
[quoted text clipped - 11 lines]
>
>Help Suggestions?

--
John Nurick [Microsoft Access MVP]

Please respond in the newgroup and not by email.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.