Solved

How to export the Access report to a text file?

Posted on 2003-12-02
5
854 Views
Last Modified: 2013-11-28
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
0
Comment
Question by:jagoho
  • 3
  • 2
5 Comments
 
LVL 6

Expert Comment

by:rvooijs
Comment Utility
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

0
 

Author Comment

by:jagoho
Comment Utility
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?
0
 
LVL 6

Expert Comment

by:rvooijs
Comment Utility
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
0
 

Author Comment

by:jagoho
Comment Utility
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.
0
 
LVL 6

Accepted Solution

by:
rvooijs earned 500 total points
Comment Utility
OK,

Here is the code for writeing to a Ascii file:

Sub test()
Dim fn As Integer

    fn = FreeFile()
    Open "h:\report.txt" For Output As #fn
    Print #fn, "Order confirmation"
    Print #fn,
    Print #fn, "Order no:"; Tab(15); "12345"
    Print #fn, "Customer no:"; Tab(15); "54321"
    Print #fn, "..."
    Close #fn
   
End Sub

Let me know ...

Robert
0

Featured Post

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Join & Write a Comment

Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now