Solved

Printing Forms

Posted on 2000-05-03
7
170 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
Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

 
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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
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 …
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…
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…

785 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