Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Query to Text File

Status
Not open for further replies.

bowserj

MIS
Dec 12, 2000
29
US
Hello all...

I have a scheduling application that I inherited, and I need to export some data into a txt format that can then be inported into another program. I have data pulled together in a query from multiple tables. What I need to do is parse through the query and manually manipulate the data before I write it to the txt file in the necesary order/format for a successful import at a later time....

Could someone please provide some insite to this for me?

Thanks, in advance....
 
G'day mate,

Could you give more info pls? How do you "manually manipulate" the data? Moving columns around? Changing data? What kind of rules would describe your manipulation?

If it's just the export part causing you drama, look for help on docmd.transfertext where you will find examples like this:

Code:
DoCmd.TransferText acExportDelim, "Standard Output", _
    "External Report", "C:\Txtfiles\April.doc"

JB
 
Do to the format required by the program that I will be importing the data into, I need to manually manipulate the data. For example, each record of the query will end up being several lines of data in the txt file, etc. Basically what I need to do is move through the query one record at a time, and access the individual fields so that I can write them to the file manually in the proper format.

I have a programming background, just not sql/access and don't know how to grab the fields or move through the data easily.

Thank you
Josh
 
You can use a recordset.

Code:
'Needs reference to Microsoft DAO 3.x Object Library
Dim rs As DAO.Recordset

Set rs=CurrentDB.OpenRecordset("NameOfQueryOrTableOrSQL")
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.CreateTextFile("c:\docs\testfile.csv", True)

Do While Not rs.EOF

  strOut=rs!Field1 & "whatever" & rs!Field2

  f.WriteLine strOut

  rs.MoveNext
Loop

f.Close
 
Why not export a report ?

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top