Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

vb Print

Posted on 2009-07-14
5
Medium Priority
?
296 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
[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
  • 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 2000 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

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…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
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 process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses

721 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