Solved

Printing a Simple Report in VB6

Posted on 2001-09-12
12
220 Views
Last Modified: 2012-06-27
I need to print a *simple* report from VB6.

Need the distributed program to be small.
Ie. Do not wish to distribute Crystal etc.

I have produced the report using datareport,but, this seems??.. to increase the size of the distributed program a lot!  Needs..MDAC_TYP.EXE (IS THIS CORRECT??) OR Am I Wrong.

-------
If I,Place the report Info formatted in list1.

Dim SEARCH As Integer
    For SEARCH = 0 To List1.ListCount - 1
        Printer.Print List1.List(SEARCH) '
    Next SEARCH
    Printer.EndDoc

I do get a result. but...

1. Can i get a printer dialog, ie windows select printer??
2. Can i put page breaks in.
--------

Appreciate any Expert Comments and Help

0
Comment
Question by:turnermich
  • 5
  • 2
  • 2
  • +3
12 Comments
 
LVL 75

Expert Comment

by:Anthony Perkins
Comment Utility
Yes, I expect that the Data Report does require MDAC_TYP.EXE.  But then if you are using any database you will also need it.  If you are not I am curious as to how you created your report.

>> 1. Can i get a printer dialog, ie windows select printer?? <<
Check out the Common Dialog control and it's method ShowPrinter.

>> 2. Can i put page breaks in. <<
Printer.NewPage
0
 

Author Comment

by:turnermich
Comment Utility
I emailed a program to a client, without the MDAC_TYP.EXE
and all ADO to the Access DatAbase etc seemed to work!!, but, The Datareport did not function.

The File is send was 2.9mg, if i included the MDAC_TYP.EXE
it increased to about 10mg.

I am pretty sure this client would not have any VB programs installed by anyone else, but, I am not SURE!

Unable to test on my computer, as i have everything for vb on it.

Would appreciate any advice as to including page breaks., and printer selection, using printer. from a list box.


Regards  Turnermich

0
 

Author Comment

by:turnermich
Comment Utility
I have tried vbformfeed,but,
it just prints a small square on the output page
0
 
LVL 4

Expert Comment

by:trkcorp
Comment Utility
Use a common dialog control to select/set a printer...

Read about the printer object in help as the subject is rather broad; but to get a small taste try the following code:
Dim pageno As Byte
For pageno = 1 To 4
   Printer.Print "The value is" & pageno
Next
Printer.EndDoc
0
 
LVL 75

Accepted Solution

by:
Anthony Perkins earned 100 total points
Comment Utility
I suggest you run the P & D Wizard and create a Setup disk.  This will tell you definitely what you need.

If you are using ADO than MDAC is already installed on the clients workstation.

>> Would appreciate any advice as to including page breaks., and printer selection, using printer. from
a list box. <<
Suggest you take a look at my first comment I answered it there.

Anthony
0
 
LVL 4

Expert Comment

by:trkcorp
Comment Utility
OH,
Just read the ? again, realized I am not telling you anything you did not already know and acperkins has already told you about printer.newpage.  Sorry...
0
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 
LVL 3

Expert Comment

by:gajendra
Comment Utility
The important properties / methods for effective printing to under windows are ...

Printer.Height
Printer.Width

Printer.CurrentX
Printer.CurrentY

Printer.Print
Printer.Circle
Printer.Line

Printer.NewPage
Printer.EndDoc
Printer.KillDoc

Get the concepts for these straight and you will be amazed at the quality of your reports.

Hope that helps

Gajendra
0
 
LVL 1

Expert Comment

by:vim_asteya
Comment Utility
eagerly waiting for the answer
0
 
LVL 49

Expert Comment

by:Ryan Chong
Comment Utility
Hi turnermich,

How about integrate your system with the M$ Word or Excel , or Even Access so that you can print your repost from them?
0
 

Author Comment

by:turnermich
Comment Utility
I have dug around in the printer.  area, eg  
as per  From: gajendra

Printer.NewPage

and elsewhere

Dim x As Printer
For Each x In Printers
   If x.Orientation = vbPRORPortrait Then
      ' Set printer as system default.
      Set Printer = x
     'MsgBox (P.DeviceName)  
      ' Stop looking for a printer.
      Exit For
   End If
Next

Which i can modify to get a list of available printers.?

-----------------

The above will work , but it seems a bit fragile to me.

Looks very much like i will have to use DataReports to get decent control on the reporting.
0
 

Author Comment

by:turnermich
Comment Utility
Sorry, i now notice acperkins gave the .NewPage 1st.
0
 

Author Comment

by:turnermich
Comment Utility
Thanks for all the helpfull comments, much appreciated

Regards  Turnermich
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
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 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…

762 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

9 Experts available now in Live!

Get 1:1 Help Now