Solved

Printing Reports Help

Posted on 2002-04-20
11
172 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
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
U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

 

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

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

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

Suggested Solutions

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

773 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