I have a table for which I have to create a report.The user must only enter the dates(from and to).The date field is present in the table.
Please help me to do this.
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:
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.
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.
i am using visual studio 2015 and trying to export data which i am importing through excel by the user selected Excel file. Now the importing part has been successfully completed i am using OLEDB Connection but Stuck in exporting the same data to a new Excel file. tried ...
I am creating a program that when you print an author, you must show all the information of all the books that the author has written. Add a new attribute in the Author class that will be "BooksWriting: List (Book)".
I have expanded the program so that it also ...
I am currently creating a simulation of a pizza ordering system in object oriented program. I have some question. the instruction and guideline is long but I will try and cut it down a lot. the instruction is to create a program that simulate a pizza restaurant using ...