Solved

Printing Forms

Posted on 2000-05-03
7
168 Views
Last Modified: 2010-05-02
I have designed 3 separate forms that include a database. I only need to print part of the data of the three forms. What is the best technique for printing text boxes on this form? I want to keep the apeparance of the text boxes. Can I print frames?  Thanks for any help
0
Comment
Question by:920gda
  • 3
  • 3
7 Comments
 
LVL 12

Accepted Solution

by:
mark2150 earned 50 total points
ID: 2774901
Printing the forms is probably the worst way to do it.

You need to drive the Printer object. You use the .Scale to set your page dimension units and then use .CurrentX/Y to position the cursor. Printer.Print will drop your text at the X/Y you've specified.

Printer.Line and .Circle will give you nice graphics.

You can adjust the .Font properties and such.

None of this is available with Print.Form. Your output will look like screen dumps and be screen/printer resolution dependent - not only that but your text will come out crappy.

M
0
 
LVL 32

Expert Comment

by:Erick37
ID: 2774918
This example uses BitBlt to copy the image of a control (Text1 in this case) to a hidden PictureBox control.  The image of the textbox is then printed using Printer.PaintPicture.


Option Explicit

Private Declare Function BitBlt Lib "gdi32" _
    (ByVal hDestDC As Long, ByVal x As Long, ByVal y As Long, _
    ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal dwRop As Long) As Long


Private Sub Command1_Click()
    Dim PrevScale As Long
    PrevScale = Me.ScaleMode
    Me.ScaleMode = 3 'Pixel
    Picture1.AutoRedraw = True
    Picture1.Width = Text1.Width
    Picture1.Height = Text1.Height
    Call BitBlt(Picture1.hDC, 0, 0, Text1.Width, Text1.Height, _
            Me.hDC, Text1.Left, Text1.Top, vbSrcCopy)
    Set Picture1.Picture = Picture1.Image
    Printer.Print ""
    Printer.PaintPicture Picture1.Picture, 100, 100
    Printer.EndDoc
    Picture1.AutoRedraw = False
    Me.ScaleMode = PrevScale
End Sub

Private Sub Form_Load()
    Picture1.Visible = False
    Picture1.BorderStyle = 0 'none
End Sub
0
 

Author Comment

by:920gda
ID: 2774960
I agree....Just wanted to make sure I was on the right track. Thanks from Macon, Ga.......
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 12

Expert Comment

by:mark2150
ID: 2775069
No problem.

Lemme know if you need code from Florida...

M
0
 

Author Comment

by:920gda
ID: 2777241
If you have an example code for drawing
boxes with the printer object, I would appreciate.
0
 
LVL 12

Expert Comment

by:mark2150
ID: 2777266
Printer.Line (x1,y1)-(x2,y2),vbblack,B

This will draw a black box with corners at x1,y1 to x2,y2 (based on your current .Scale).

You can position your text to print inside it with:

Printer.CurrentX = X1 + TinyBitForMargin
Printer.CurrentY = Y1 + TinyBitForMargin
Printer.Print Text1.Text

M
0
 

Author Comment

by:920gda
ID: 2778071
Thanks Mark.....
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

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

757 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now