txt file always leave last few records

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • kkshansid
    New Member
    • Oct 2008
    • 232

    txt file always leave last few records

    while printing txt file my code always leave last few records however large database table I use
    Code:
    Function prntxt()
    CNT = 1
    sPath = "F:\" ' just have the directory here
    Set rs = CurrentDb.OpenRecordset("SELECT * FROM ABC ORDER BY EMP_NO")
    Open sPath & "SC.TXT" For Output As #1
    Print #1, "S NO EMPL  NO     NAME"
    Print #1, String(133, "*")
    
    Do Until rs.EOF
    Print #1, CNT; Tab(7); rs("EMP_NO"); Tab(15); rs("NAME")
    ''Print #1, CNT
    CNT = CNT + 1
    If (CNT Mod 30 = 1) Then
    Print #1, Chr(12)
    End If
    rs.MoveNext
    Loop
    rs.Close
    Set rs = Nothing
    MsgBox "FILE PRINTED SUCCESSFULLY"
    End Function
  • univercel
    New Member
    • Aug 2013
    • 11

    #2
    Code:
    If (CNT Mod 30 = 1) Then
    This line may be the culprit.

    Comment

    • jimatqsi
      Moderator Top Contributor
      • Oct 2006
      • 1288

      #3
      Repeat line 14 between line 17 and 18. That is, do another FF after you finish looping through the file. If you want to be precise, make sure that you didn't end on a multiple of 30 to avoid doing two FF in a row with nothing in between.

      Jim

      Comment

      • kkshansid
        New Member
        • Oct 2008
        • 232

        #4
        the problem is corrected by closing the file in end

        Comment

        Working...