|
-
Feb 15th, 2001, 11:40 AM
#1
Thread Starter
Member
I saw on one of these posts were someone had a neat way to print the grid. It showed the grid lines and everything. I have a real long grid and would like to print it and have it seperate the pages as need be. Any suggestions how I would go about this?
PBSnake
-
Feb 15th, 2001, 12:26 PM
#2
PowerPoster
my simple solution
I have a better example somewhere, but this may get you going in the right direction...
Code:
'The long-winded print process
'currentX and currentY used to accurately align columns
'THIS PROCESS A LITTLE SLOWER, BUT MORE EFFICIENT
'Could have used "TAB()", "SPC()",or "," , but had
'undesirable results
Private Sub cmdPrint_Click()
'Reminder to User
MsgBox "Please Make Sure That The Printer Is Ready...", vbCritical, "Printer Ready?"
Dim TROWS, DPAGES, IPAGES, TPAGES, ENDNUM As Long
'Determines Number of Records divisible by 20 and remainder
TROWS = Data2.Recordset.RecordCount
DPAGES = TROWS / 20
IPAGES = Int(DPAGES)
'Determine Number of Pages for Print
If DPAGES - IPAGES = 0 Then
TPAGES = DPAGES
Else
TPAGES = IPAGES + 1
End If
'Error Handling for printer problems
On Error Resume Next
'Setup Global for printer
Printer.Orientation = 2 'Landscape
Printer.Font = ARIAL
Printer.FontSize = 6
'Begin Loop to Start Printing
For X = 1 To TPAGES
'Prints "Header" Information
Printer.CurrentY = 0
Printer.CurrentX = 100
Printer.Print ""
Printer.Print ""
Printer.CurrentX = 200
Printer.Print "PATENT PLANT SERVICES - DATA VIEWER - Listing by Plant"
Printer.Print ""
Printer.CurrentX = 200
Printer.Print "CURRENT SCAFFOLD LIST FOR : " & DBCombo1.Text
Printer.Print ""
Printer.CurrentX = 200
Printer.Print Data2.Recordset.RecordCount & " SCAFFOLDS ASSIGNED TO THIS PLANT as of " & txtDateTime.Text
Printer.Print ""
Printer.CurrentY = 1700
Printer.CurrentX = 200
Printer.Print "---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------"
Printer.CurrentY = 1900
Printer.CurrentX = 200
Printer.Print MSFlexGrid1.TextArray(0) 'Tag
Printer.CurrentY = 1900
Printer.CurrentX = 1100
Printer.Print MSFlexGrid1.TextArray(1) 'Workorder No.
Printer.CurrentY = 1900
Printer.CurrentX = 2600
Printer.Print MSFlexGrid1.TextArray(2) 'Location
Printer.CurrentY = 1900
Printer.CurrentX = 6700
Printer.Print MSFlexGrid1.TextArray(3) 'Zone Planner
Printer.CurrentY = 1900
Printer.CurrentX = 10000
Printer.Print MSFlexGrid1.TextArray(4) 'Area Supervisor
Printer.CurrentY = 1900
Printer.CurrentX = 12000
Printer.Print MSFlexGrid1.TextArray(5) 'Build Date
Printer.CurrentY = 1900
Printer.CurrentX = 13000
Printer.Print MSFlexGrid1.TextArray(6) 'Daily Rental
Printer.CurrentY = 1900
Printer.CurrentX = 14000
Printer.Print MSFlexGrid1.TextArray(7) 'Extended Rental
Printer.CurrentX = 200
Printer.Print "---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------"
'Determines where to stop the loop
If X = TPAGES Then
ENDNUM = TROWS
Else
ENDNUM = 20 * X
End If
'For Loop to Create Pages to Print
'(20 indicates number of records to print on page)
For Y = 1 + (20 * (X - 1)) To ENDNUM
'Determines where to set CurrentY Position W/ Regard to Next Sheet
If X > 1 Then
Nxtrow = 400 * (Y - (20 * (X - 1)))
Else
Nxtrow = 400 * Y
End If
'Builds the Table Determined by CurrentX and CurrentY,
'along with row and sheet consideration
Printer.CurrentY = 2000 + Nxtrow
Printer.CurrentX = 200
Printer.Print MSFlexGrid1.TextMatrix(Y, 0) 'Tag
Printer.CurrentX = 200
Printer.Print "---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------"
Printer.CurrentY = 2000 + Nxtrow
Printer.CurrentX = 1100
Printer.Print MSFlexGrid1.TextMatrix(Y, 1) 'Workorder No.
Printer.CurrentX = 200
Printer.Print "---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------"
Printer.CurrentY = 2000 + Nxtrow
Printer.CurrentX = 2600
Printer.Print MSFlexGrid1.TextMatrix(Y, 2) 'Location
Printer.CurrentX = 200
Printer.Print "---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------"
Printer.CurrentY = 2000 + Nxtrow
Printer.CurrentX = 6700
Printer.Print MSFlexGrid1.TextMatrix(Y, 3) 'Planner
Printer.CurrentX = 200
Printer.Print "---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------"
Printer.CurrentY = 2000 + Nxtrow
Printer.CurrentX = 10000
Printer.Print MSFlexGrid1.TextMatrix(Y, 4) 'Area Supervisor
Printer.CurrentX = 200
Printer.Print "---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------"
Printer.CurrentY = 2000 + Nxtrow
Printer.CurrentX = 12000
Printer.Print Format(MSFlexGrid1.TextMatrix(Y, 5), "MM/DD/YYYY") 'Build Date
Printer.CurrentX = 200
Printer.Print "---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------"
Printer.CurrentY = 2000 + Nxtrow
Printer.CurrentX = 13000
Printer.Print Format(MSFlexGrid1.TextMatrix(Y, 6), "CURRENCY") 'Daily Rental
Printer.CurrentX = 200
Printer.Print "---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------"
Printer.CurrentY = 2000 + Nxtrow
Printer.CurrentX = 14000
Printer.Print Format(MSFlexGrid1.TextMatrix(Y, 7), "CURRENCY") 'Extended Rental
Printer.CurrentX = 200
Printer.Print "---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------"
Next Y
'Prints "Footer" Information
Printer.CurrentY = 10750
Printer.CurrentX = 200
Printer.Print "Sheet " & Printer.Page; " of " & TPAGES
Printer.CurrentY = 10950
Printer.CurrentX = 200
Printer.Print "Current Daily Rental : " & txtTTLDaily.Text
Printer.NewPage
Next X
Printer.EndDoc
End Sub
Let me know if this helps...
Remaining quiet down here !!!
BRAD HAS GIVEN ME THE ULTIMATIVE. I have chosen to stay....
-
Feb 15th, 2001, 02:27 PM
#3
Thread Starter
Member
Thanks for the code Example. I will go through it and see how it works. Thanks for the assistance and good codeing to you.
PBSnake
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
|