VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Create your own Data Report in text file format, No need to use any third party Report writer, Try

by Fayyaz Butt (2 Submissions)
Category: Databases/Data Access/DAO/ADO
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Wed 28th December 2005
Date Added: Mon 8th February 2021
Rating: (1 Votes)

Create your own Data Report in text file format, No need to use any third party Report writer, Try its very easy....

API Declarations


' You must add Filescripting reference in your project before run this routine
' This is sample report from generic table, plz set data fields according to your database

Dim Fs, Glfile
Dim fvlonLineCount As Long
Dim fvbooExitPrintLine As Boolean
Dim fvintPageNo As Integer

Dim rsGeneric As New ADODB.Recordset ' any Generic Recordset
Dim CN As ADODB.Connection ' set your connection
Dim Rs As New ADODB.Recordset ' set your recordset


Rate Create your own Data Report in text file format, No need to use any third party Report writer, Try



    PrintLine ""
    PrintLine ""
    PrintLine Chr(27) & Chr(14) & Chr(27) & Chr(15) & "FAYYAZ BUTT"
    PrintLine Chr(27) & Chr(77) & "Any Heading you want to print" & String(113, " ") & Format(Format(Date, "mmmm d, yyyy"), String(20, "@"))
    PrintLine ""
    PrintLine String(147, "=")
                                                                               
   End Sub

Sub PageFooter()
    fvintPageNo = fvintPageNo + 1
    PrintLine String(147, "-")
    PrintLine " " & "Any text you want to print at footer" & String(100, " ") & "Page : " & Format(fvintPageNo, "@@@") & Chr(18)
    PrintLine ""
    PrintLine ""
End Sub

Sub PrintLine(AnyLine As String)
    fvlonLineCount = fvlonLineCount + 1
    Glfile.WriteLine AnyLine
End Sub


Private Sub Command1_Click()
Set rsGeneric = cn.execute "select * from anytable" ' give your table name here
    
    Dim lvstrCritaria As String
    Dim lvstrPreviousACode As String
    Dim lvintWait As Integer
    Dim lvbytCount As Byte

            
            fvlonLineCount = 0
            fvbooExitPrintLine = False
            fvintPageNo = 0
            Set Fs = CreateObject("scripting.filesystemobject")
            Set Glfile = Fs.CreateTextFile("c:\MyTextfile.txt", True)
            '*** Report Header ***
            Call PageHeader
            '*** Detail Section ***
            rsGeneric.MoveFirst
            Do Until rsGeneric.EOF
                ' set your table fields here
                PrintLine rsGeneric!acno & " | " & rsGeneric!head
                rsGeneric.MoveNext
            Loop
            '*** Report Footer ***
            PrintLine String(79, " ") & String(45, "-")
            PrintLine "*** End of Report ***"
            Call PageFooter
            '*** End Of Report ***
            Glfile.Close
            Screen.MousePointer = 0
            MsgBox "Your report has been printed in the file" & Chr(13) & App.Path & "\MyTextfile.TXT", vbInformation, "Report Printed"
End Sub



Download this snippet    Add to My Saved Code

Create your own Data Report in text file format, No need to use any third party Report writer, Try Comments

No comments have been posted about Create your own Data Report in text file format, No need to use any third party Report writer, Try . Why not be the first to post a comment about Create your own Data Report in text file format, No need to use any third party Report writer, Try .

Post your comment

Subject:
Message:
0/1000 characters