Solved

vb Print

Posted on 2009-07-14
5
288 Views
Last Modified: 2013-12-26
How to add code below to increase the font of  len(trim(h.h1)) ?
I just want to increase the font of the heading of my printing. Please help me!
Thanks!
Private Sub OfficialReceipt_LOCAL(trxno As String)
Dim rs      As DAO.Recordset
Dim STR     As String
Dim i       As Double
Set rs = dbLocal.OpenRecordset("SELECT * FROM DETAILS WHERE DOCNO='" & saveDocNo & "' ORDER BY ROWNO ASC")
        Open OpenPort_ For Output As #1
        
        i = Len(Trim(H.H1))
        i = i \ 2
        i = 20 - i
        If i = 20 Then
        Else
            STR = Space(i) & Trim(H.H1)
            Print #1, STR
        End If
        Print #1, "Customer : " & Trim(Setmeup(0))
        If i = 20 Then
        Else
            STR = Space(i) & Trim(H.H6)
            'Print #1, STR
        End If
            Print #1, String(40, "_")
            Print #1, "DESCRIPTION   QTY      PRICE      AMOUNT"
            Print #1, String(40, "-")
            Set rs = Nothing
            For i = 0 To NoLineFeed
            Next
            Close #1
Set rs = Nothing
End Sub

Open in new window

0
Comment
Question by:Whing Dela Cruz
  • 3
  • 2
5 Comments
 
LVL 16

Expert Comment

by:HooKooDooKu
ID: 24849243
The problem as I see it is that you are attempting to print to a file.  Printing to a file basically limits you to text only.

On the other hand, if you print to the VB printer (using "Print" rather than "Print #1"), then you will be printing through the print driver.  In this case, the VB printer object has properties such as Font settings that allow you to control the current Font used by the print driver.

But as long as you continue to print to a file, the only way to change the font is to know what printer the file will eventually be printed on and used the Esc codes that that printer uses to change the font properties.  But that would mean your output would only be valid for that printer.  On the other hand, that's a part of the purpose for Windows and things like the VB Printer object and print drivers... so that a programer can print to the generic windows printer and the output will be like you want regardless of the printer printed to (within the limits of the print driver for that printer).
0
 

Author Comment

by:Whing Dela Cruz
ID: 24849413
Hi!  I attemp to use the code below just to insest  my idea inspite of the comment you had just sent to me but i do not know if this scenario can solved my problem. When i try this, the heading will not locate to upper portion but its position will always display below. In my code, Can I assign the heading to the top side of the report? If yes, please tell me how! Thanks    
Private Sub OfficialReceipt_LOCAL(trxno As String)
    Set PRN = Printer
    PRN.ScaleMode = 2
    PRN.CurrentX = 30: PRN.CurrentY = 15
    Dim fnt As New StdFont
    fnt.Name = "Verdana": fnt.Size = 14: fnt.Bold = True
    Set PRN.Font = fnt
    PRN.Print "My Heading"
 
Dim rs      As DAO.Recordset
Dim STR     As String
Dim i       As Double
Set rs = dbLocal.OpenRecordset("SELECT * FROM DETAILS WHERE DOCNO='" & saveDocNo & "' ORDER BY ROWNO ASC")
        Open OpenPort_ For Output As #1
        Print #1, ""
        Print #1, ""
        Print #1, "" & PRN.print; "My heading"
        Print #1, "Customer : " & Trim(Setmeup(0))
        If i = 20 Then
        Else
            STR = Space(i) & Trim(H.H6)
            'Print #1, STR
        End If
            Print #1, String(40, "_")
            Print #1, "DESCRIPTION   QTY      PRICE      AMOUNT"
            Print #1, String(40, "-")
            Set rs = Nothing
            For i = 0 To NoLineFeed
            Next
            Close #1
Printer.EndDoc
Set rs = Nothing
End Sub

Open in new window

0
 

Author Comment

by:Whing Dela Cruz
ID: 24849427
Sorry, the  line 17 is not working..
0
 
LVL 16

Accepted Solution

by:
HooKooDooKu earned 500 total points
ID: 24850696
Use the properties 'Printer.CurrentX' and 'Printer.CurrentY' to position the cursor on the logical print page.  I believe dimensions are in twips (1440 twips = 1 inch) and retative to the printable margins of the page (not the edge of the page).

This means you might need to update CurrentX and CurrentY at the start of each line, and again you need to be using Print ... rather than Print #1...

BTW, to modify the Font, you can use Printer.Font  The main properties of the font you are likely to play with are:
Printer.Font.Bold
Printer.Font.Size
Printer.Font.Italic
Printer.Font.Underline
Printer.Font.Name   (which font, Arial, Times New Roman, Courier, etc).

...

Ok, now that I've taken a closer look at your example, it looks like you are getting closer and you're using this commands.  Here's my suggestion until you get a handle on how this is going to work, use the Printer object directly (rather than assigning it to PRN) and completely get rid of 'Print #1" and PRN.Print.
Private Sub OfficialReceipt_LOCAL(trxno As String)
    Printer.ScaleMode = 2
    Printer.Font.Name = "Verdana"
    Printer.Font.Size = 14
    Printer.Bold = True
    Printer.CurrentX = 30: Printer.CurrentY = 15
    Print "My Heading"
 
Dim rs      As DAO.Recordset
Dim STR     As String
Dim i       As Double
Set rs = dbLocal.OpenRecordset("SELECT * FROM DETAILS WHERE DOCNO='" & saveDocNo & "' ORDER BY ROWNO ASC")
    Printer.CurrentX = 30
    Printer.CurrentY = 30
    Print "Customer : " & Trim(Setmeup(0))
    Print String(40, "_")
    Print "DESCRIPTION   QTY      PRICE      AMOUNT"
    Print String(40, "-")
    Set rs = Nothing
    For i = 0 To NoLineFeed
    Printer.CurrentX = 30
    Printer.CurrentY = 30 + 15* i
    Print RS.Desc
    Next
    Printer.EndPage
    Printer.EndDoc
Set rs = Nothing
End Sub

Open in new window

0
 

Author Closing Comment

by:Whing Dela Cruz
ID: 31603206
Thank you so much to you. the code is working. More power! Thanks!
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
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…
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…

774 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