Microsoft Knowledge Base Email Alertz

When you use the OutputTo method or OutputTo action to save a report to a text file (.txt), blank lines are randomly added to the text file. NOTE : This behavior can also occur when you use the Export command to save a report to a

Search KbAlertz

Advanced Search

Receive Microsoft Knowledge Base articles by E-Mail?

Every night we scan the Microsoft Knowledge Base. If technologies you're interested in are updated, we'll send you an e-mail. You only get one e-mail a day, and only when new articles are added.

Click here to create a
FREE account
Already have an account?
[Click here to Login]











Microsoft Knowledge Base Article

This article contents is Microsoft Copyrighted material.
©2005-©2007 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks

Article ID: 208436 - Last Review: June 24, 2004 - Revision: 2.0

ACC2000: Report OutputTo Text File Adds Random Blank Lines

This article was previously published under Q208436
Moderate: Requires basic macro, coding, and interoperability skills.

This article applies to a Microsoft Access database (.mdb) and to a Microsoft Access project (.adp).

On This Page

SYMPTOMS

When you use the OutputTo method or OutputTo action to save a report to a text file (.txt), blank lines are randomly added to the text file.

NOTE: This behavior can also occur when you use the Export command to save a report to a text file; in this case, the Save formatted check box in the Export Report ReportName As dialog box is automatically selected.

CAUSE

This behavior occurs because a text file does not have the same vertical spacing options as a report in Microsoft Access. When you output a report to a text file, the text file contains 8 lines per inch. If the Height of the report's Detail section is set for a different number of lines per inch, for example 6 lines per inch (.1667), then blank lines are automatically added.

RESOLUTION

To resolve this behavior, set the Height property of a report's detail section to a value divisible by .125 inches. For example, if the detail section's Height property contains a fractional number, set the fractional portion of this property value to one of the following decimal equivalents:
   Fraction   Decimal Equivalent
   -----------------------------
   1\8        .125
   1\4        .25
   3\8        .375
   1\2        .5
   5\8        .625
   3\4        .75
   7\8        .875
				
When the height of the Detail section is divisible by .125 inches, the spacing is consistent (without extra, random blank lines) because the data from the report is output at 8 lines per inch.

MORE INFORMATION

Steps to Reproduce Behavior

CAUTION: If you follow the steps in this example, you modify the sample database Northwind.mdb. You may want to back up the Northwind.mdb file and follow these steps on a copy of the database.

  1. Start Microsoft Access and open the sample database Northwind.mdb or the sample project NorthwindCS.adp.
  2. In the Database window, click Reports, and then click New, to create a new, blank report based on the Employees table and open it in Design view.
  3. Add a text box with a label to the Detail section and set the following properties:
    Label
    Caption: LastName:
    Left: 1"
    Top: 0"
    Width: 1"
    Height: .1667"

    Text Box
    ControlSource: LastName
    Left: 2"
    Top: 0"
    Width: 2"
    Height: .1667"
  4. In the Detail section, set the Height property to .1667" (the same height as LastName).
  5. Close and save the report as Report1.
  6. Press CTRL+G to display the Immediate window.
  7. Type the following line and press ENTER:
    DoCmd.OutputTo acReport, "Report1", acFormatTXT, "Report1.txt", True
    When you open Report1.txt in a text editor, several random blank lines appear in the file, for example:
       Last Name:        Davolio
       Last Name:        Fuller
    
       Last Name:        Leverling
       Last Name:        Peacock
       Last Name:        Buchanan
    
       Last Name:        Suyama
       Last Name:        King
       Last Name:        Callahan
    
       Last Name:        Dodsworth
    						

REFERENCES

For more information about OutputTo Action, in the Visual Basic Editor, click Microsoft Visual Basic Help on the Help menu, type OutputTo Action in the Office Assistant or the Answer Wizard, and then click Search to view the topic.

APPLIES TO
  • Microsoft Access 2000 Standard Edition
Keywords: 
kbprb kbusage KB208436
       

Community Feedback System

Very often, it takes hours to solve a problem. Very often, you've looked high and low, and have tried a lot of solutions. When you finally found it, chances are, it was because someone else helped you. Here's your chance to give back. Use our community feedback tool to let others know what worked for you and what didn't.

Please also understand that the community feedback system is not warranted to be correct, it's simply a system that we've built to let people try and help each other. If something in a feedback response doesn't make sense to you, or you're not comfortable making changes that the feedback talks about (like registry edits), please consult a professional.

Thank you for using kbAlertz.com Feedback System.

-- Scott Cate