Solved

Printing Reports Help

Posted on 2002-04-20
11
175 Views
Last Modified: 2010-08-05
Hey People - I have made the following which does work, but Im no expert and need a little bit of help - The following will print, but over two pages and what I want it to do is do it on one and then, if need be, go to a second page and so on.

I also need code to place a margin top and bottom - you will find the constants set in the program except Im not sure how to set them...

If you could put a few basic comments in as well, that would be great... Thanks :)

You can download the project here : http://www.hypermax.net.au/~user/hollstar/taxcalc.zip
0
Comment
Question by:hollstar
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 5
11 Comments
 
LVL 4

Expert Comment

by:TomLaw1999
ID: 6955886
What size of paper are you using hollstar? and
what size of paper do you have in your printer settings?.
0
 

Author Comment

by:hollstar
ID: 6955966
8 Wide, 11.5 Long...
0
 
LVL 4

Expert Comment

by:TomLaw1999
ID: 6955997
Does your papersize match the size shown in the printer paper settings?
I am trying to determine whether this is a programming fault or simply a printer setup problem.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:hollstar
ID: 6956833
Just average letter size - In word it says, 21.59 , 27.94
0
 

Author Comment

by:hollstar
ID: 6956852
Look as it stands now, the program prints fine, all I need is a margin at the top and bottom, and for it to use the 3rd & fth column before going to the next page...
0
 
LVL 4

Accepted Solution

by:
TomLaw1999 earned 50 total points
ID: 6957688
OK Hollstar try this. (I cannot test it at this end because there is no printer connected to my laptop but give it a try

Option Explicit

' Column locations
Private Const csngCol1 As Single = 1.5
Private Const csngCol2 As Single = 3.5

' Margin Locations
Private Const csngWidth As Single = 8.5 ' Page Width
Private Const cintHeight As Integer = 11 ' Page Height
Private Const cintTop As Integer = 1 ' Top Margin
Private Const cintBottom As Integer = 1 ' Bottom Margin

Private Sub cmdExit_Click()
Unload frmMain
End Sub

Private Sub cmdPrint_Click()
Dim psngMinimum As Single
Dim psngMaximum As Single
Dim pintIncrement As Integer
Dim psngRate As Single
Dim psngLastY As Single
Dim psngInterest As Single
Dim pstrData As Single
Dim col2 As Long

psngMaximum = Val(txtMaximum)

pintIncrement = Val(txtIncrement)


    For psngMinimum = Val(txtMinimum) To psngMaximum
   
    'set the top margin
        If Printer.CurrentY < cintTop Then Printer.CurrentY = cintTop
        psngLastY = Printer.CurrentY
         

        ' Make sure there is room on the page to
        ' print the line.
        If Printer.CurrentY >= cintHeight - cintBottom - cintTop Then
            If col2 = 0 Then
               col2 = 3
               Printer.CurrentY = cintTop
               Else
               Printer.NewPage
               col2 = 0
            End If
           
            psngLastY = Printer.CurrentY
        End If
       
        Call PrintIntField(psngMinimum, csngCol1 + col2, _
            psngLastY)
       
        Call PrintSngField(psngMinimum * txtRate, csngCol2 + col2, _
            psngLastY)
    Next
   
    Printer.EndDoc
   
End Sub

Private Sub Form_Load()
    Printer.ScaleMode = vbInches
    Printer.FontSize = 12
    Printer.FontName = "Arial"
    Printer.DrawWidth = 10
End Sub

Private Sub PrintSngField(psngInterestRate As Single, psngXRight As Single, psngY As Single)
    Dim psngWidth As Single
    Dim pstrData As String
    pstrData = Format(psngInterestRate, "Currency")
    psngWidth = Printer.TextWidth(pstrData)
    Printer.CurrentX = psngXRight - psngWidth
    Printer.CurrentY = psngY
    Printer.Print pstrData
End Sub

Private Sub PrintIntField(pintData As Single, _
    psngXRight As Single, psngY As Single)
    Dim psngWidth As Single
    Dim pstrData As String
    pstrData = CStr(pintData)
    psngWidth = Printer.TextWidth(pstrData)
    Printer.CurrentX = psngXRight - psngWidth
    Printer.CurrentY = psngY
    Printer.Print Format(pstrData, "Currency")
End Sub
0
 
LVL 4

Expert Comment

by:TomLaw1999
ID: 6957698
The variable col2 may need to be ammended to give you the correct column shift however I think you will be able to follow the logic and make it suit your needs.

I have set up a top margin, you seem to have already set up a bottom margin.
0
 

Author Comment

by:hollstar
ID: 6957711
Have not done a print test yet, but just reading the status from the system tray, I noticed it said 2 pages...

Will check in the morning...
0
 

Author Comment

by:hollstar
ID: 6957723
Just checked then and it was a bottom margin issue - Needed to be changed to .05 It should now work...
0
 
LVL 4

Expert Comment

by:TomLaw1999
ID: 6957805
Thanks for the 'A' hollstar.
0
 

Author Comment

by:hollstar
ID: 6958331
Not a worry! I mean, it works, you came back with a working fast response, so I think it should be an A Plus !

Thanks Again - BTW : I did not change those columns, just the bottom margin...
0

Featured Post

Enroll in May's Course of the Month

May’s Course of the Month is now available! Experts Exchange’s Premium Members and Team Accounts have access to a complimentary course each month as part of their membership—an extra way to increase training and boost professional development.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question