Solved

How to export the Access report to a text file?

Posted on 2003-12-02
5
874 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

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

If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
This article describes two methods for creating a combo box that can be used to add new items to the row source -- one for simple lookup tables, and one for a more complex row source where the new item needs data for several fields.
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
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…

734 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