| | |
Vb report generation
Please support our Visual Basic 4 / 5 / 6 advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Oct 2006
Posts: 14
Reputation:
Solved Threads: 0
The first thing you want to do is select data that needs to be included in the report. So, write a small function like this:
Of course, I am assuming that user will enter date in text fields txtFromDate and txtToDate.
Next thing you want to do is to print the data on to a form. Include a picturebox on the form. Print to that picturebox.
I have only given the skeleton of the report generator. I have not included any error handling. I have not included page handling, report totals, etc. I assume ADO references are included in your project.
You can do the same thing with printer instead of picturebox, but with some exceptions like printer.enddoc, to send the report to printer. See VB help on enddoc, printer orientation, etc. if you wish to send it to printer.
Let me know if you need more help.
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
private function GetSQL() as string dim sql as string sql = "Select * from mytable" sql = sql & " Where myDate <= #" & txtFromDate & "#" sql = sql & " And myDate >= #" & txtToDate & "#" GetSQL = sql end function
Of course, I am assuming that user will enter date in text fields txtFromDate and txtToDate.
Next thing you want to do is to print the data on to a form. Include a picturebox on the form. Print to that picturebox.
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
private sub printReport() dim rs as ADODB.Recordset dim curY as integer dim th as integer set rs = new ADODB.recordset rs.connnection = cnn 'assuming this is opened on form load, etc. rs.open GetSQL(), adopenstatic picture1.cls picture1.currentx = 1250 picture1.currenty = 210 picture1.fontname = "Arial" picture1.fontsize = 12 th = picture1.textHeight("junk") picture1.print "Heading for Report" curY = 210 + th + 100 'border from header do while not rs.eof printFld 100, curY, rs.field(0) printFld 400, curY, rs.field(1) 'so on for other fields rs.movenext curY = curY + th if curY > picture1.height then exit do loop rs.close end sub private sub printFld (x as integer, y as integer, s as string) picture1.currentx = x picture1.currenty = y picture1.print s; 'you may skip the semi colon end sub
I have only given the skeleton of the report generator. I have not included any error handling. I have not included page handling, report totals, etc. I assume ADO references are included in your project.
You can do the same thing with printer instead of picturebox, but with some exceptions like printer.enddoc, to send the report to printer. See VB help on enddoc, printer orientation, etc. if you wish to send it to printer.
Let me know if you need more help.
![]() |
Similar Threads
- Issue about passing parameter to Crystal Report 11.. (Visual Basic 4 / 5 / 6)
- Noob Needing Help with data report (Visual Basic 4 / 5 / 6)
- How to mail a report automatically from web. (PHP)
- VB.NET: how to generate report of transaction in ebanking project (VB.NET)
- Reports generation in VB6 (Visual Basic 4 / 5 / 6)
Other Threads in the Visual Basic 4 / 5 / 6 Forum
- Previous Thread: Sqlserver 2005 Express Edition
- Next Thread: Wasnt sure where to put this
| Thread Tools | Search this Thread |
* 6 429 2007 access activex add age append application basic beginner birth bmp calculator cd cells.find click client code college column component connection connectionproblemusingvb6usingoledb copy creat ctrl+f data database datareport date delete dissertations dissertationthesis dissertationtopic edit error excel excelmacro file filename form hardware header iamthwee image inboxinvb internetfiledownload keypress label listbox listview liveperson login looping machine microsoft movingranges number objectinsert open oracle password prime program prompt range-objects readfile reading record refresh remotesqlserverdatabase report retrieve save search sendbyte sites sort sql sql2008 sqlserver subroutine table tags textbox time urldownloadtofile vb vb6 vb6.0 vba visual visualbasic visualbasic6 web window windows





