Results 1 to 6 of 6

Thread: How to print data from vb

  1. #1

    Thread Starter
    Fanatic Member noielen's Avatar
    Join Date
    Nov 2005
    Location
    Cebu, Phil.
    Posts
    680

    How to print data from vb

    Somebody can help me on how to print (to printer) data from database query in vb access. I have a code on how to print grid/form, but what if more records and more than one page. What also I want is just like you are printing from "MS word or .doc". I want to print it as a report.
    noister
    <advertising link removed by moderator>

  2. #2
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    Re: How to print data from vb

    You can either use a report tool or use the Printer object directly. With the Printer object you get the most freedom but it also requires you to write all the code yourself.
    VB Code:
    1. Printer.Print "Hello"
    2. Printer.NewPage
    3. Printer.Print "Page 2"
    4. Printer.EndDoc
    The above is of course pretty useless by itself but it does show you how to print text and to create a new page and finally how to end the printing (which will let the spooler take over and actually do the printing). You set the position you want to print something with the CurrentX and CurrentY properties. The Printer object also allows you to draw simple graphics like lines and circles as well as to draw images.

  3. #3

    Thread Starter
    Fanatic Member noielen's Avatar
    Join Date
    Nov 2005
    Location
    Cebu, Phil.
    Posts
    680

    Re: How to print data from vb

    can you give some sample code(s) on how to put some graphics? or other references to help my problems? Actualy I already used that code you've provided. But problem is how to print the next page? I put all datas on a grid before user can print (I add button where user click to print). Any help please. I think this is just a very simple for others.hehe... any can help me...tnx in advance.

  4. #4
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    Re: How to print data from vb

    Well, using the NewPage method will create a new page and any printing done after that is made on the new page. You can use the PaintPicture method to draw graphics in the same manner as you would do with a PictureBox or the Form. Here is the full documentation of the Printer object.

  5. #5

    Thread Starter
    Fanatic Member noielen's Avatar
    Join Date
    Nov 2005
    Location
    Cebu, Phil.
    Posts
    680

    Re: How to print data from vb

    thanks, but hope you can provide more ideas.
    noister
    <advertising link removed by moderator>

  6. #6
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: How to print data from vb

    Moved to Reporting section.
    Quote Originally Posted by noielen
    thanks, but hope you can provide more ideas.
    The two ways to print are to use the printer object, which Joacim has covered, or, as he also suggested, use a reporting tool. There are no other ideas.

    If you do not wish to use the printer object, then you would need to decide which of the several reporting tools available are best suited for your needs.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width