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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Crystal Viewer and DLL

Status
Not open for further replies.

CasperTFG

Programmer
Nov 15, 2001
1,210
US
Hey everyone, I'm posting this for a co-worker. I tried to help her but I am at a loss and can't find anything in the forum like this.

Every time we I get to the point of printing, viewing or exporting we get the error message: Object Required... Each place it errors is in red.
Code:
Public Sub PrintRpt(frm As Form, prt As Integer)
   Dim g_AppReport As CRAXDRT.Application
   Dim g_Report As CRAXDRT.Report  'HOLDS REPORT
   Dim j As Long
     
   g_SERVERNM = "imnr"
   c_DBNM = "imnr"
   g_USERID = "imnrpt"
   g_PASSWD = "imnrpt"
   
    On Error GoTo CERR
   Set g_AppReport = CreateObject("CrystalRuntime.Application")
        
    Set g_Report = g_AppReport.OpenReport("C:\IMN.rpt")
    g_Report.Database.LogOnServer "crdb_oracle.dll", g_SERVERNM, c_DBNM, g_USERID, g_PASSWD
    
    
   For j = 1 To g_Report.Database.Tables.Count
            g_Report.Database.Tables(j).SetLogOnInfo g_SERVERNM, c_DBNM, g_USERID, g_PASSWD
   Next
       
    g_Report.ParameterFields(1).SetCurrentValue frm.txtSD.Text, 12
    
    g_Report.DisplayProgressDialog = False
    g_Report.EnableParameterPrompting = False
      
        If prt = 0 Then
            [COLOR=red] g_Report.PrintOut[/color]
        Else
            If prt = 1 Then
                
[COLOR=red]                 frmIMN.CRViewer.ReportSource = g_Report[/color]
                frmIMN.CRViewer.ViewReport             'LINK VIEWER TO REPORT IN frmIMN
                frmIMN.Visible = True
            Else
                g_Report.ExportOptions.DiskFileName = c_DEXPPATH + "IMN_REPORTS\" + g_RptNM + frm.txtSD.Text + ".doc"
                g_Report.ExportOptions.FormatType = 14
                g_Report.ExportOptions.DestinationType = 1
                [COLOR=red] g_Report.Export[/color]
                frm.Refresh
            End If
        End If
    While Not (g_Report.PrintingStatus.Progress = crPrintingCompleted)
        DoEvents
    Wend
    Set g_Report = Nothing
    Exit Sub
CERR:
    If frm.Name = "frmIMN" Then
        frmERR.lblErr.Caption = " Monthly Failed. Error: " + Err.Description
        frmERR.lblAct.Caption = "Please Reprint  Monthly manually. "
        frmERR.Show vbModal
    End If
    Set g_Report = Nothing
    Err.Raise Err.Number
End Sub



Casper

There is room for all of gods creatures, "Right Beside the Mashed Potatoes".
 
This might be a longshot, because the code itself is sound. I ran a test, and it checks out fine.

But, if my CRViewer control is named incorrectly, I get errors in pretty much the same places.

-dave
 
I usually force the report to re-read the records, especially as you may have changed both the database information and the parameters.

try
Code:
    g_Report.DisplayProgressDialog = False
    g_Report.EnableParameterPrompting = False
    [COLOR=blue]g_Report.ReadRecords[/color]

        If prt = 0 Then

Take Care

Matt
If at first you don't succeed, skydiving is not for you.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top