Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Print A Table Using VB6 1

Status
Not open for further replies.
Dec 17, 2006
8
CA
What is the most simple method to be able to print a table ( as
shown below ) on paper ? I tried with arrays but had no success.

Month Income Expenses Misc
Jan 50000 14000 500
Feb 60000 13000 700
March 70000 16000 300
April 80000 5000 1000

Thanks for any suggestions

GubertDisentis




 
Try using the DataReport for this.
Easiest way then would be to create an ADODB recordset, add the fields and data, and then pass it to the DataReport.
 
Start a new project.
Create a DataReport (Project|Data Report add), and name it "Report1". (If the menu item "Project|Data Report add" isn't available, then go first to Project|Components| and the "Designer" tab and check "Data Report")

Go to the Report1 report designer and add two RptTextBoxes into the Details section and set their DataField properties to:

1. Field1Text
2. Field2LongInt

In the DataReport's code window past this:
Code:
[COLOR=blue]
Public Sub OpenMe(rsDataSource As ADODB.Recordset)
    Set Me.DataSource = rsDataSource
    Me.WindowState = 2
    Me.Show vbModal 
End Sub
[/color]

Add a new form. We'll name it "Form1"
Add a Command button to the form. Name it "Command1"
Go to the Form's code window and add this:
Code:
[COLOR=blue]
Public rsDynaReport As ADODB.Recordset
Private Sub Command1_Click()
    Dim Rpt1 As DataReport1
    Set rsDynaReport = New ADODB.Recordset
    With rsDynaReport
        .Fields.Append "Field1Text", adVarWChar, 50, adFldIsNullable Or adFldUpdatable
        .Fields.Append "Field2LongInt", adInteger, , adFldIsNullable Or adFldUpdatable
    
        .Open
        .AddNew Array("Field1Text", "Field2LongInt"), Array("MyText", 123)
        .Update
        .MoveFirst
    End With
    Set Rpt1 = New DataReport1
    Call Rpt1.OpenMe(rsDynaReport)
End Sub
[/color]

Set the Project's Start-up object to Form1 (Project|Properties|Staup Object)

Run the project and click on Command1.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top