Results 1 to 6 of 6

Thread: Printing Data Report in VB 6

  1. #1

    Thread Starter
    Member
    Join Date
    Mar 2006
    Posts
    34

    Printing Data Report in VB 6

    Hi

    I developed a database application in VB 6 and included data reports, fed with ado data objects. I tested and it worked fine on my machine (which I used for development).

    When I packaged and installed on my client's machine, the data report did not print, giving at times errors. I tried many things, and after a week of hard work, I found out that I needed to install VB 6 and all its components on the client's machine for the data report to print.

    So, on all machines on which there is no VB installed, the print does not work. Once I install VB 6 and all its components. It does. Problem is that my clients do not want to be bothered about having to install VB 6 (which they will never use, since they are not developers), and they are 150% right.

    Can anyone help me out in telling me how I can get the data report to print without having to install VB6 on a machine. At least if I could get to know the component which is needed in the installation, I would have packaged it along. Thanks in advance.

    Best regards

  2. #2
    Just Married shakti5385's Avatar
    Join Date
    Mar 2006
    Location
    Udaipur,Rajasthan(INDIA)
    Posts
    3,747

    Re: Printing Data Report in VB 6

    what type of error occuring there

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

    Re: Printing Data Report in VB 6

    What are you using as a deployment tool?

  4. #4
    Just Married shakti5385's Avatar
    Join Date
    Mar 2006
    Location
    Udaipur,Rajasthan(INDIA)
    Posts
    3,747

    Thumbs up Re: Printing Data Report in VB 6

    VB Code:
    1. Private Sub CREPORT_Click()
    2. On Error GoTo ErrorTrap
    3.  
    4. TSQL = ""
    5. TSQL = "SELECT * FROM LEAVE_TABLE WHERE FIRM='" & COMFIRMNAME.Text & "' AND S_DATE BETWEEN #" & DTP1.Value & "# and #" & DTP2.Value & "#"
    6. Set RTMP = Get_Special_Record_Set(TSQL)
    7.  
    8. If RTMP.RecordCount = 0 Then
    9. MsgBox "Record Not Found", vbInformation
    10. Exit Sub
    11. End If
    12.  
    13.  
    14. With FIRM_STATUS
    15.     Set .DataSource = Nothing
    16.     Set .DataSource = RTMP.DataSource
    17. End With
    18. 'firm status is datareport name
    19. 'don't forget to write all control in section 1 of your report
    20. 'coding by banna
    21. With FIRM_STATUS.Sections("Section1").Controls
    22.    
    23.     .Item("LD1").Caption = DTP1.Value
    24.     'label first name ld1
    25.     .Item("LD2").Caption = DTP2.Value
    26.     'label second name ld2
    27.     .Item("TXTFIRM").DataMember = ""
    28.     .Item("TXTFIRM").DataField = RTMP.Fields("FIRM").Name
    29.     'textbox first name txtfirm
    30.     'firm is field firm in the table
    31.     .Item("TXTLOCATION").DataMember = ""
    32.     .Item("TXTLOCATION").DataField = RTMP.Fields("LOCATION").Name
    33.     'txtbox second name txtlocation
    34.     'location is field location in the table
    35.     .Item("LABNOEMP").Caption = EMP
    36.     'label third name labnoemp
    37.     .Item("LSALARY").Caption = Val(SALARY)
    38.     'label lsalary name lsalary
    39. End With
    40. FIRM_STATUS.Refresh
    41. 'firm_status is datareport name
    42.  
    43. FIRM_STATUS.Show
    44. ErrorTrap:
    45. If Err.Number <> 0 Then
    46.    MsgBox "Error (" & Err.Number & "): " & Err.Description, vbCritical, "Error"
    47. End If
    48. End Sub

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

    Re: Printing Data Report in VB 6

    Moved to reporting section.

  6. #6

    Thread Starter
    Member
    Join Date
    Mar 2006
    Posts
    34

    Re: Printing Data Report in VB 6

    Hi Shakti and Hack

    Thanks for replying to my thread.

    To answer your question, Hack, I am using Visual Studio 6's package and deployment wizard.

    Shakti, the errors that I get are of tw types. Either I get an error message speaking of an object which is not created or initialise (or something like this), or I don't get anything at all. Everything seems to be working fine, but the document does not print.

    I am pasting the codes for one module which does the printing:

    VB Code:
    1. Public Sub printInvoice()
    2.     Dim title As String
    3.    
    4.     Err.Clear
    5.     On Error Resume Next
    6.    
    7.     adoPrint.RecordSource = "select * from salesdetails where salesid = " & lastSalesID
    8.     adoPrint.Refresh
    9.        
    10.     Set repWholesaleSalesInvoice.DataSource = adoPrint
    11.    
    12.     title = "Date: " & vbTab & vbTab & txtDate.text & vbTab & _
    13.             Format(txtTime.text, "HH:mm") & vbCrLf & vbCrLf & _
    14.             "Rcpt/Inv. No.: " & vbTab & vbTab & receiptNumber & vbCrLf
    15.                
    16.     client = cboClient.text
    17.     If Split(client, " ")(0) <> "NONAME" Then
    18.         title = title & "Client: " & vbTab & vbTab & client
    19.     End If
    20.    
    21.     repWholesaleSalesInvoice.Sections(1).Controls(3).Caption = title
    22.     repWholesaleSalesInvoice.Sections(5).Controls(2).Caption = "Salesperson: " & salespersonCode
    23.    
    24.     repWholesaleSalesInvoice.Hide
    25.     repWholesaleSalesInvoice.printReport
    26.        
    27.     If Err.Number <> 0 Then
    28.         MsgBox "Error generating invoice: " & vbCrLf & Err.description
    29.     End If
    30. End Sub

    The headers which you set at run time, I set them at design time.

    All I need to know now is how to get my application running and printing reports on a machine which does not have VB6 installed.

    Thanks a lot, dudes.
    Here from you soon.

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