Create your own Data Report in text file format, No need to use any third party Report writer, Try its very easy....
This bit of code will create a data report as a .txt file, thus eliminating the need for a third-party reporting application. To make it work, you must add a file scripting reference in your project before running this code. In addition, the author notes that this snippet creates a sample report from a generic table, so be sure to set the data fields according to your database.
Author: VBCode.com
Target User: Developer/Architect
DECLARATIONS:
Option Explicit
' 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
CODE
Sub PageHeader()
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