|
-
May 19th, 2007, 12:32 PM
#1
Thread Starter
Junior Member
Printing Reports Using VB6
Hi,
I am currently trying to finish my assignment for college. I have to create a VB6 application using ADO to front an MS Access database. It is a based on a group of solicitors , and i have to allow add,delete edit records ect.
I have almost finished the assignment, but one of the main things we need to beable to do is to print Reports from an SQL query. i.e "All Solicitor Details Grouped by Grade".
The problem i am having is i just cannot for the life of me, get the report to print out neatly. the 1st few records come out neatly, but then it goes wonky, and whatever i try, just does not work.
Could somebody please help me as this is the last thing i need to do to finish the assignment, and i am really struggling.
Code:
Private Sub cmdPrintReport_Click()
On Error Resume Next
sqlReport = "SELECT * FROM SolicitorQuery"
Set rs1 = cn1.Execute(sqlReport)
' Printer Headers
rs1.MoveFirst
While Not rs1.EOF
Printer.FontBold = True ' makes font bold
Printer.FontSize = 18 ' sets the font size for the headers
pline = String(62, " ")
Mid(pline, 27, 35) = "Solicitor Details in order of Grade"
Printer.Print pline
Printer.FontSize = 12
Printer.FontBold = False
pline = String(121, "*")
Printer.Print pline
Printer.Print ""
pline = String(121, " ")
Mid$(pline, 12, 12) = "Solicitor ID"
Mid$(pline, 35, 5) = "Title"
Mid$(pline, 50, 7) = "Surname"
Mid$(pline, 66, 8) = "Initials"
Mid$(pline, 81, 5) = "Grade"
Mid$(pline, 93, 7) = "Partner"
Mid$(pline, 107, 11) = "Description"
Printer.Print pline
Printer.Print ""
pline = String(150, ".")
Printer.Print pline
'Print Data
While Not rs1.EOF
Printer.Print ""
pline = String(140, " ")
Mid$(pline, 12, 5) = rs1!Solicitor_ID
Mid$(pline, 38, 7) = rs1!Title
Mid$(pline, 55, 20) = rs1!Surname
Mid$(pline, 78, 7) = rs1!Initials
Mid$(pline, 92, 5) = rs1!Grade
Mid$(pline, 103, 8) = rs1!Partner
Mid$(pline, 115, 19) = rs1!Description
Printer.Print pline
rs1.MoveNext
Wend
Wend
Printer.EndDoc
End Sub
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|