Solved

How to export the Access report to a text file?

Posted on 2003-12-02
5
861 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
ID: 9865330
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
ID: 9870116
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
ID: 9873261
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
ID: 9880153
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
ID: 9881921
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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

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…
I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …

776 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