Dear Mr.Amit,
Here below is the code written and used
by self to generate a text file. How to
use it and send to printer hope you know.
Quote :
*******
'I have kept the report path in a table
savepath = rsReport!Rptpath
fname1 = savepath & a
b= "Report Heading"
ffopen1 = FreeFile
Open fname1 For Output As #ffopen1
Line1 = Chr(27) & Chr(14) & Space(3) & b & Chr(20) & Chr(27)
Print #1, Line1
Print #1, ""
'Line1 = Space(13) & Format(Startdtpick.Value, "DD/MM/YYYY") & " To " & Format(Enddtpick.Value, "DD/MM/YYYY")
Line1 = Space(3) & "Period : " & Format(Startdtpick.Value, "MMM-DD-YYYY") & " To " & Format(Enddtpick.Value, "MMM-DD-YYYY")
Print #1, Line1
Print #1, Space(7) & "(Sub Heading)" & Chr(27) & Chr(15)
Print #1, ""
Print #1, "======================================================================================================="
Line1 = "Report Columns here "
Print #1, Line1
Print #1, "======================================================================================================="
Print #1, ""
Dim n As Double
n = 0
With rs
If Not (rs.EOF And rs.BOF) Then rs.MoveFirst
While Not .EOF
Dim s
s = Space(6)
n = n + 1
tf = rs!md2 + rs!mr2 + rs!mot1
ff = (rs!md4 + rs!md5 + rs!mr5 + rs!mot2)
Line1 = Format(n, "#00") & ". " & Space(5) & !secname & Space(40 - Len(!secname)) & IIf(IsNull(Format(rs!md2, "#0")), 0, Format(rs!md2, "#0")) & Space(5) & IIf(IsNull(Format(rs!md4, "#0")), 0, Format(rs!md4, "#0")) & Space(5) & IIf(IsNull(Format(rs!md5, "#0")), 0, Format(rs!md5, "#0")) & Space(5) & IIf(IsNull(Format(rs!mr2, "#0")), 0, Format(rs!mr2, "#0")) & Space(5) & IIf(IsNull(Format(rs!mr5, "#0")), 0, Format(rs!mr5, "#0")) & Space(5) & IIf(IsNull(Format(rs!mot1, "#0")), 0, Format(rs!mot1, "#0")) & Space(5) & IIf(IsNull(Format(rs!mot2, "#0")), 0, Format(rs!mot2, "#0")) & Space(6) & IIf(IsNull(Format(tf, "#0")), 0, Format(tf, "#0")) & Space(5) & IIf(IsNull(Format(ff, "#0")), 0, Format(ff, "#0"))
tf = 0
ff = 0
tmd2 = tmd2 + rs!md2
tmd4 = tmd4 + rs!md4
tmd5 = tmd5 + rs!md5
tmr2 = tmr2 + rs!mr2
tmr5 = tmr5 + rs!mr5
tmot1 = tmot1 + rs!mot1
tmot2 = tmot2 + rs!mot2
Print #1, Line1
.MoveNext
Wend
ttf = tmd2 + tmr2 + tmot1
fff = (tmd4 + tmd5 + tmr5 + tmot2)
Print #1, ""
Print #1, "======================================================================================================="
Line1 = " G R A N D T O T A L " & Space(22) & IIf(IsNull(Format(tmd2, "#0")), 0, Format(tmd2, "#0")) & Space(5) & IIf(IsNull(Format(tmd4, "#0")), 0, Format(tmd4, "#0")) & Space(5) & IIf(IsNull(Format(tmd5, "#0")), 0, Format(tmd5, "#0")) & Space(5) & IIf(IsNull(Format(tmr2, "#0")), 0, Format(tmr2, "#0")) & Space(5) & IIf(IsNull(Format(tmr5, "#0")), 0, Format(tmr5, "#0")) & Space(5) & IIf(IsNull(Format(tmot1, "#0")), 0, Format(tmot1, "#0")) & Space(5) & IIf(IsNull(Format(tmot2, "#0")), 0, Format(tmot2, "#0")) & Space(5) & IIf(IsNull(Format(ttf, "#0")), 0, Format(ttf, "#0")) & Space(5) & IIf(IsNull(Format(fff, "#0")), 0, Format(fff, "#"))
Print #1, Line1
Print #1, "======================================================================================================="
Dim teu
teu = ttf + ((fff) * 2)
Print #1, "Total : " & Format(teu, "###0") & " Teus."
Print #1, "" // Blank Line
Print #1, "" // Blank Line
Print #1, "Generated on : " & Format(Date, "MMM-DD-YYYY") & Space(2) & Format(Time, "HH:MM:SS")
Print #1, ""
Print #1, "End of Report : " & st
Print #1, Chr(27) & Chr(14)
End With
Close ffopen1
rs.Close
Unquote :
*********
Trust above helps.
Rgds
Menon, Cochin.