How to print report from VB?


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 7 of 7

Thread: How to print report from VB?

  1. #1
    Alam Guest

    How to print report from VB?


    I have an application which does not use any form. So, I can not use Crystal
    Report control here. I know there is an object Printer in Printers collection
    in VB. I am trying to print through it. It prints but first line starts very
    top left corner. Also, I want to add headers and titles to that report too.
    I am getting hard time in printing text on my required places in a report.
    Can any one help me ?


  2. #2
    Alan Gillott Guest

    Re: How to print report from VB?

    Actually, you can use a form but just not display it
    Form.Visible=false

    Alam <ALAMSAF@HOTMAIL.COM> wrote in message news:38ee53e3$1@news.devx.com...
    >
    > I have an application which does not use any form. So, I can not use

    Crystal
    > Report control here. I know there is an object Printer in Printers

    collection
    > in VB. I am trying to print through it. It prints but first line starts

    very
    > top left corner. Also, I want to add headers and titles to that report

    too.
    > I am getting hard time in printing text on my required places in a report.
    > Can any one help me ?
    >




  3. #3
    Ryan Guest

    Re: How to print report from VB?


    "Alam" <ALAMSAF@HOTMAIL.COM> wrote:
    >
    >I have an application which does not use any form. So, I can not use Crystal
    >Report control here. I know there is an object Printer in Printers collection
    >in VB. I am trying to print through it. It prints but first line starts

    very
    >top left corner. Also, I want to add headers and titles to that report too.
    >I am getting hard time in printing text on my required places in a report.
    >Can any one help me ?
    >

    you don't need to add the crystal report component object to use crystal
    reports. Just make a reference to the crystal report engine.
    that or you could always use the data environment to create reports.


  4. #4
    Phil Weber Guest

    Re: How to print report from VB?

    Alam: As Ryan suggests, your options are:

    1. Use the Crystal Reports print engine, which doesn't=20
    require the use of an OCX. For more information, visit=20
    http://support.seagatesoftware.com ;

    2. If you're using VB6 Enterprise Edition, use the included=20
    DataReport Designer;

    3. Use a third-party reporting tool, such as Data Dynamics'=20
    ActiveReports=20
    ( http://www.datadynamics.com/products...ts/arinfo.html =
    );

    4. Use VB's Printer object.

    As you've discovered, option 4 is a lot of work. You must write code to=20
    create margins (Hint: see the CurrentX and CurrentY properties in VB's=20
    online help), print your own headers and footers, etc. If you're =
    inclined=20
    to go with option 4, you might download a trial copy of VideoSoft's=20
    VSView control ( http://vs.videosoft.com/vsview/info/default.asp ) and=20
    see if it makes things easier for you.
    ---
    Phil Weber



  5. #5
    Alam Guest

    Re: How to print report from VB?


    I have one problem. I want to print the report to the printer dircetly without
    showing any dialog control or message.

    Options:
    1: Crystal report engine can only print to the window I guess. Thats what
    I found from their kb.
    2:I don't know if I can print reports to printer with VB Data Report Designer
    and how advanced reports can be printed through it.
    3: I will wait on it.
    4: I have downloaded an evaluation copy. The vs printer object must be placed
    on form to print a report.

    Now what should I do ???


    "Phil Weber" <pweber@teleport.com> wrote:
    >Alam: As Ryan suggests, your options are:
    >
    > 1. Use the Crystal Reports print engine, which doesn't=20
    > require the use of an OCX. For more information, visit=20
    > http://support.seagatesoftware.com ;
    >
    > 2. If you're using VB6 Enterprise Edition, use the included=20
    > DataReport Designer;
    >
    > 3. Use a third-party reporting tool, such as Data Dynamics'=20
    > ActiveReports=20
    > ( http://www.datadynamics.com/products...ts/arinfo.html

    =
    >);
    >
    > 4. Use VB's Printer object.
    >
    >As you've discovered, option 4 is a lot of work. You must write code to=20
    >create margins (Hint: see the CurrentX and CurrentY properties in VB's=20
    >online help), print your own headers and footers, etc. If you're =
    >inclined=20
    >to go with option 4, you might download a trial copy of VideoSoft's=20
    >VSView control ( http://vs.videosoft.com/vsview/info/default.asp ) and=20
    >see if it makes things easier for you.
    >---
    >Phil Weber
    >
    >



  6. #6
    Ryan Guest

    Re: How to print report from VB?


    the report engine can print to either the window or to the printer by setting
    the destination property. printer is equal to 1 and the screen is default
    I *believe* and it is = 0.
    ex.
    CryReports.Destination = 1
    CryReports.Action = 1
    would print your report to the printer.

    The data report designer bundled with studio 6 is very similiar to crystal
    reports in that you got your header, details and footer sections and its
    easy to repeat data in it. However, it lacks the flexibility of crystal
    reports and the ability to create great looking graphs built right into the
    reports. Overall, I would just ignore the data report unless you need a
    quick and dirty plain database report and don't want the overhead that crystal
    reports causes.

    As for the printer object, you do not need a form. it can be directly accessed
    as an object, or if you have multiple printers, you can use the collection
    called printers. Refer to MSDN for specific examples, keyword = printers
    will get you to it.

    "Alam" <alamsaf@hotmail.com> wrote:
    >
    >I have one problem. I want to print the report to the printer dircetly without
    >showing any dialog control or message.
    >
    >Options:
    >1: Crystal report engine can only print to the window I guess. Thats what
    >I found from their kb.
    >2:I don't know if I can print reports to printer with VB Data Report Designer
    >and how advanced reports can be printed through it.
    >3: I will wait on it.
    >4: I have downloaded an evaluation copy. The vs printer object must be placed
    >on form to print a report.
    >
    >Now what should I do ???
    >
    >
    >"Phil Weber" <pweber@teleport.com> wrote:
    >>Alam: As Ryan suggests, your options are:
    >>
    >> 1. Use the Crystal Reports print engine, which doesn't=20
    >> require the use of an OCX. For more information, visit=20
    >> http://support.seagatesoftware.com ;
    >>
    >> 2. If you're using VB6 Enterprise Edition, use the included=20
    >> DataReport Designer;
    >>
    >> 3. Use a third-party reporting tool, such as Data Dynamics'=20
    >> ActiveReports=20
    >> ( http://www.datadynamics.com/products...ts/arinfo.html

    >=
    >>);
    >>
    >> 4. Use VB's Printer object.
    >>
    >>As you've discovered, option 4 is a lot of work. You must write code to=20
    >>create margins (Hint: see the CurrentX and CurrentY properties in VB's=20
    >>online help), print your own headers and footers, etc. If you're =
    >>inclined=20
    >>to go with option 4, you might download a trial copy of VideoSoft's=20
    >>VSView control ( http://vs.videosoft.com/vsview/info/default.asp ) and=20
    >>see if it makes things easier for you.
    >>---
    >>Phil Weber
    >>
    >>

    >



  7. #7
    Adam Dawes Guest

    Re: How to print report from VB?

    > 4: I have downloaded an evaluation copy. The vs printer object must be
    placed
    > on form to print a report.


    You can use a control such as this without actually displaying the form. If
    you don't already have a visible form on which you can place the control,
    create a new form and put the control on there. You can then use the control
    within the form as much as you like, and the form will not be displayed. The
    form will only become visible if you call its Show method (or set its
    Visible property to True).

    --

    Adam.





Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center