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 trying to create a library management system which is supposed to be used to store/keep infp for the library and the library members( book title, author, name and picture for borrower and other stuffs). The app has 6 buttons, delete, save, add,previsous,next, and upload( for upload ...
Im trying to bind my custom vertical scrollbar to datagridview is this possible.. Please help Thnak you..
I have two tables, I will call them first-half and second-half (of the year)
Table: first id jan feb mar apr ----------------------- 2 80 90 70 60 3 50 40 60 30 Table: second id jan feb mar apr ----------------------- 2 50 70 60 90 3 80 60 50 ...