• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 474
  • Last Modified:

CRYSTAL REPORT THROUGH A NETWORKED COMPUTER

I have a VB6 program that I deploy through an intranet.. My server is running on a different computer.. My application is installed in another computer.. My application runs a Crystal Report.. The reports folder is in the client computer.. However, it won't work!!

I tried using the server as the client also (meaning, I am running my application in the computer where the server is located --- the reports folder is there too) and then it worked!!

Is there a special code needed if the application is connecting to a server from a different computer for the reports to run??

Also, does the reports folder need to be where the server/database is located?? Is there a way to code that in my application?? (like RunReport <ip add of server>\reports folder\report name, i guess..)

Here's my code
----------------
'This is upon clicking the View Report button
Private Sub cmdView_Click()

If cmbReports.ListIndex < 0 Then Exit Sub
RunReport App.Path & "\reports\" & cmbReports & ".rpt"

End Sub
----------------
'This is the Run Report procedure
Private Sub RunReport(ByVal vstrFileName)

  On Error GoTo err_handler
   
    Dim period As String
    Dim emptype As String
    Dim empid As Integer
   
    On Error GoTo err_handler
   
    period = txtPeriod.Text
    emptype = DataCombo1.Text
    empid = txtID.Text
   
    With frmPayReports.cr
        .Reset
       
       Select Case cmbReports
            Case "Attendance Summary"
                .ParameterFields(0) = "pID;" & txtID.Text & ";TRUE"
            Case "Credit Union Summary"
                .Formulas(0) = "period = '" & txtPeriod.Text & "' "
                .Formulas(1) = "type = '" & DataCombo1.Text & "' "
                .ParameterFields(0) = "pPeriod;" & txtPeriod.Text & ";TRUE"
                .ParameterFields(1) = "pType;" & DataCombo1.Text & ";TRUE"
            Case "GSIS Summary"
                .Formulas(0) = "period = '" & txtPeriod.Text & "' "
                .Formulas(1) = "type = '" & DataCombo1.Text & "' "
                .ParameterFields(0) = "pPeriod;" & txtPeriod.Text & ";TRUE"
                .ParameterFields(1) = "pType;" & DataCombo1.Text & ";TRUE"
            Case "Others Summary"
                .Formulas(0) = "period = '" & txtPeriod.Text & "' "
                .Formulas(1) = "type = '" & DataCombo1.Text & "' "
                .ParameterFields(0) = "pPeriod;" & txtPeriod.Text & ";TRUE"
                .ParameterFields(1) = "pType;" & DataCombo1.Text & ";TRUE"
            Case "Payslip"
                .Formulas(0) = "period = '" & txtPeriod.Text & "' "
                .ParameterFields(0) = "pPeriod;" & txtPeriod.Text & ";TRUE"
                .ParameterFields(1) = "pID;" & txtID.Text & ";TRUE"
            Case "Payroll Sheet"
                .Formulas(0) = "period = '" & txtPeriod.Text & "' "
                .Formulas(1) = "type = '" & DataCombo1.Text & "' "
                .ParameterFields(0) = "pPeriod;" & txtPeriod.Text & ";TRUE"
                .ParameterFields(1) = "pType;" & DataCombo1.Text & ";TRUE"
            Case "RATA Payroll"
                .Formulas(0) = "period = '" & txtPeriod.Text & "' "
                .Formulas(1) = "type = '" & DataCombo1.Text & "' "
                .ParameterFields(0) = "pPeriod;" & txtPeriod.Text & ";TRUE"
        End Select
       
        .ReportFileName = vstrFileName
        .WindowTitle = cmbReports.Text
        .WindowState = crptMaximized
        .Action = 1
    End With
   
Exit Sub

err_handler:
    MsgBox "Printing is not allowed.", vbExclamation, "Print"
    'MsgBox (Err.Description), vbInformation
    Exit Sub

End Sub
--------------
'This is my Class Module
Function PrintFile(ByVal Trans As String, ByVal strFileName As String, ByVal intDestination As Integer, ByVal strFormula As String)
 On Error GoTo errhandler
   
        Dim myFile As String
             myFile = App.Path & "\Reports\" & strFileName
        If intDestination = 0 Then frmReports.cr.Destination = crptToWindow
        If intDestination = 1 Then frmReports.cr.Destination = crptToPrinter
        If intDestination = 2 Then
            frmReports.cr.PrintFileType = crptWinWord
            frmReports.cr.Destination = crptToFile
        ElseIf intDestination = 3 Then
            frmReports.cr.PrintFileType = crptExcel50
            frmReports.cr.Destination = crptToFile
        End If
        frmReports.cr.ReportFileName = myFile
        frmReports.cr.SelectionFormula = strFormula
 
 'Crystal Report Action
    frmReports.cr.Action = 1

   
Exit Function
errhandler:
 MsgBox (Err.Description), vbExclamation

End Function
--------------

Hope you can help me.. I badly need this to work.. :(
0
jlmabutas
Asked:
jlmabutas
  • 5
  • 3
1 Solution
 
frodomanCommented:
The first place I'd look is at the datasource of your report.  If you designed the report pointing to a local database and then move the report it isn't going to work (unless the identical db is also on the new system).  I don't see you setting the datasource in your code so are you using a dsn inside your report?  Does that dsn exist on the client computer?
0
 
mlmccCommented:
What database?

How did you install the applicatiion on the client machine?  Did you build an installation package and install it or simply copy the executable?

mlmcc
0
 
jlmabutasAuthor Commented:

frodoman:

A dsn exist on the client computer. We set the ip address of the server in the connection string (conn.________). The code for that is in another module…that works since the application can retrieve records from the server, it just wont display the reports. By the way, if you use a dsn inside the report, where should it be? Coz i dont remember setting anything there/




mlmcc:

We are using MySQL. We packaged  the application using  package & deployment wizard.
0
Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

 
jlmabutasAuthor Commented:
I just remembered.. I'm using a User DSN/System DSN.. And the report refers to this.. I just read that it applies only to a certain computer..

Does that mean I have to use a File DSN instead (which I read is machine-independent)??

And does the report have to be referred to this File DSN?? If so, will it work if I just update the reports and use the Set Location.. dialog to change the DSN that it is referring to??
0
 
jlmabutasAuthor Commented:
Wait... I also re-checked my code and it seems that I just set the datasource in my code (in the connection string) for the other functions of the application and not for the report...

If I have to place it in my code, HOW WILL I DO THAT?? Is there a specific code for that??

Or if I should just use a dsn inside the report.. again, HOW WILL I DO THAT??
0
 
mlmccCommented:
This is for Access but it does show how to change the data source

http://support.businessobjects.com/communityCS/FilesAndUpdates/SCR8_VB_RDC_DBPassword.exe.asp

mlmcc
0
 
jlmabutasAuthor Commented:
mlmcc,
Hi.. I tried opening the Visual Basic Project but errors occurred when it loaded the Crystal Report1 file (the Visual Basic Designer Module).. I don't know why.. Do you have any other samples??
0
 
jlmabutasAuthor Commented:
Hey.. I solved it already.. I think I really had to check the DSN.. I had to use a File DSN instead of just a User and System DSN..
0
 
mlmccCommented:
Great.  No i don't have other samples and the errors are probably because the app includes a different Crystal library than you have.

mlmcc
0

Featured Post

[Webinar] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

  • 5
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now