Export to text routine

  • Thread starter Thread starter Nick Cooper
  • Start date Start date
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
 
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
 
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
 
Back
Top