Results 1 to 2 of 2

Thread: Fixed Length Text File with Write # Statement

  1. #1
    Guest

    Unhappy

    Need to output a recordset in a fixed length format to a text file using the Print# or Write# statement.

    This is what I have so far but when the field is longer than what the tab allows it writes it on the next line instead of forcing it on the same line (or writing over the existing field) Please Help!!



    Open "test3.txt" For Output As #1

    While Not rs.EOF

    Print #1, Tab(0); rs.Fields("Ship_To_ID"); Tab(14); rs.Fields("Ship_To_Name"); Tab(39); rs.Fields("Ship_To_Address_1");
    Print #1, Tab(64); rs.Fields("Ship_To_City");



    rs.MoveNext
    Wend
    Close #1

  2. #2
    Lively Member
    Join Date
    Jan 2000
    Location
    Neenah, WI USA
    Posts
    95

    Fixed Length Text...

    My approach is lo-tech.

    x = space(100) ' or whatever the length
    mid(x,1,13) = rs.fields("Ship_to_ID")
    mid(x,14,25) = rs.fields("Ship_to_name")
    mid(x,39,25) = rs.fields("Ship_to_Address_1")
    mid(x,64,25) = rs.fields("Ship_to_City")

    print#1, x

    kind of manual, but it works for me. If a field is too long for the allocated space, it gets dumped. I'd rather do that than overwrite the city with part of a street address.

    Hope this helps.
    Steve

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width