Export to text routine

N

Nick Cooper

I have a small database in Acc2K with a routine to export
a query to txt file. This will not run in Acc2k runtime,
but all other code does. I think this is because the code
uses the export to text wizard.is there another way of
doing this?

Any suggestions gratefully rec'd.

Nick
 
G

Guest

Nick,

Have you tried the WriteLine method of the FileSyetem
Object.

Just one word of caution, later versions of Access may not
allow the runtime versions to create objects.

Hope that this helps.

Robin
 
N

Nick Cooper

I have now tried the writeline approach (see code below)
and still get the same runtime error. Any other thoughts
from anyone or is a full copy of Acc2k the only answer?

Nick

Dim db As DAO.Database
Dim rs As DAO.Recordset
Set db = CurrentDb()
Set rs = db.OpenRecordset("SELECT * from
[linebyline_output];")
Set fs = CreateObject("Scripting.FileSystemObject")
Set a = fs.CreateTextFile("z:\excel.dat", True)
If rs.RecordCount <> 0 Then
Do
'MsgBox rs.Fields("output")
a.writeline rs.Fields("output")
rs.MoveNext
Loop Until rs.EOF
End If
MsgBox "File successfully exported"
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top