Solved

Printing Reports Help

Posted on 2002-04-20
11
170 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
  • 6
  • 5
11 Comments
 
LVL 4

Expert Comment

by:TomLaw1999
Comment Utility
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
Comment Utility
8 Wide, 11.5 Long...
0
 
LVL 4

Expert Comment

by:TomLaw1999
Comment Utility
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
 

Author Comment

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

Author Comment

by:hollstar
Comment Utility
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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 4

Accepted Solution

by:
TomLaw1999 earned 50 total points
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Thanks for the 'A' hollstar.
0
 

Author Comment

by:hollstar
Comment Utility
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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Problem to delete range 4 54
DO Loop not working 4 62
VB error "Type mismatch" 2 42
Sending a email via excel using vba 6 55
Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

762 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

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now