?
Solved

Printing Forms

Posted on 2000-05-03
7
Medium Priority
?
186 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 200 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

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

839 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