Solved

How to export the Access report to a text file?

Posted on 2003-12-02
5
868 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

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

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

A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

679 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