?
Solved

Printing Reports Help

Posted on 2002-04-20
11
Medium Priority
?
179 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

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 200 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

650 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