Solved

Printing Reports Help

Posted on 2002-04-20
11
176 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
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

 

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

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
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…

726 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