Link to home
Start Free TrialLog in
Avatar of jagoho
jagoho

asked on

How to export the Access report to a text file?

I can export the Access report to a text file, but it is not the same format in the text file.
I got the following code. Can someone please help me?

Private Sub Print_Click()
    Const stTempName As String = "C:\temp.txt"
    Dim stDocName As String
    stDocName = "OrdersQuery"
    DoCmd.OutputTo acOutputReport, stDocName, acFormatTXT, stTempName, True
End Sub
Avatar of rvooijs
rvooijs

Hi,

You might consider exporting to HTML or Rich Text Format (acFormatHTML, acFormatRTF).
This wouldn't exectly create a textfile, would it would keep your format intact (sort of).

You could even export to a snapshot (acFormatSNP). This keeps the formatting best
but users would need the snapshot viewer to view the report so I don't think it's what your looking for.

If you really need an Ascii text file, it can't be done by exporting a report.
You will have to write the file line by line though basic.

Are these options for you ? Let me know ...

Robert

Avatar of jagoho

ASKER

I think my only choice is to write the file line by line.

Actually my original problem is that I have to print an Access report to a dot-matrix printer without extra blank space (remainder of current page). So far I only know how to do this in DOS mode with a text file.

So I think my only option is to write the file line by line though basic.I did think about using this way, but my report is about Orders and Order Details. I don't know how to write Order Details part. Do you have any way or code can help me?
Hi,

How will printing the text file solve your printer problems ?
Are you going to send a FormFeed after each page ? If so, why not print
the Access Report and then send the FormFeed?

By the way, I have had these problems printing to a matrix printer myself.
I think the solutions was to make sure all printer settings (windows, access and
on the printer) had the right paper size.

If somehow you find a solutions that works even when the user messes up his
settings, I would like to know it too.

Robert
Avatar of jagoho

ASKER

Hi Robert,

I only can print an Access report to a dot-matrix printer without extra blank space (remainder of current page) in DOS mode.  But it only can print text file in DOS mode so I output my report to a text file then print it.
ASKER CERTIFIED SOLUTION
Avatar of rvooijs
rvooijs

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial