[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

Question
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

8.0

Access denied Error when Doing an Export to PDF.

Asked by pra_kumar03 in Crystal Reports Software

Tags: function, access

Hi all
I am getting an access denied error ( error code -2147206458) when i try to use the export option. does anyone has any clue about it? Also on the machine on which i am trying this out, it works with one of the ID's but with id i am trying it fails.
Attached is the code which we are using.


Public Function DO_Crystal(iFileNum As Integer, szRunDate As String, szRunState As String, szRptCode As String, szBrkStr As Integer, szBrkEnd As Integer, szPageCnt As Integer, szReportName As String) As Integer
    Dim Report As CRAXDDRT.Report
    Dim conn As ADODB.Connection
    Dim rs As ADODB.Recordset
    Dim crystal As CRAXDDRT.Application
    Dim iRetval As Integer
    Dim szsql As String
    Dim sPrnName As String
    Dim sCmd As String
    Dim sPDFPath As String
    On Error GoTo Err_handler
    CrystalActiveXReportViewer1.EnableRefreshButton = False
   
   
    Set conn = New ADODB.Connection
    conn.ConnectionString = "DRIVER={SQL Server};" _
        & "SERVER=" + gCtlServer + ";" _
        & "DATABASE=" + gCtlAggrDb + ";" _
        & "UID=" + GsUserID + ";" _
        & "PWD=" + GsPassword + ";"
       
 
    conn.Open
   
    szsql = "UPDATE Trig_Tbl"
    szsql = szsql + " SET run_state = '" + "CRB" + "'  "
    szsql = szsql + " WHERE   run_date = '" + szRunDate + "'"
    szsql = szsql + " AND report_code = '" + szRptCode + "'"
    conn.Execute szsql
   
    Set rs = New ADODB.Recordset
   
    Select Case szReportName
        Case "LB.rpt":
            rs.Open "select * from fl_1_bl", conn, adOpenStatic, adLockReadOnly
            sPrnName = gszBPrinterName
        Case "L31.rpt":
            rs.Open "select * from fl_2_bl", conn, adOpenStatic, adLockReadOnly
            sPrnName = gszLPrinterName
        Case "L60.rpt":
            rs.Open "select * from Lp_3_fl", conn, adOpenStatic, adLockReadOnly
            sPrnName = gszLPrinterName
        Case "IL31.rpt":
            rs.Open "select * from lp_4_fl", conn, adOpenStatic, adLockReadOnly
            sPrnName = gszLPrinterName
        Case "IL60.rpt":
            rs.Open "select * from mac_1", conn, adOpenStatic, adLockReadOnly
            sPrnName = gszLPrinterName
           
        'Tcs change begins - 07/19/2005
        Case "PerInf.rpt"
            rs.Open "select * from dbo.PerInftbl", conn, adOpenStatic, adLockReadOnly
            sPrnName = gszLPrinterName ' change 1
        Case "PerInf_ErrRpt.rpt"
            rs.Open "select * from dbo.PerInftbl", conn, adOpenStatic, adLockReadOnly
            sPrnName = gszLPrinterName ' change 1
        'Tcs change ends - 07/19/2005
    End Select
    MsgBox "Setting New Crytal Object"
    Set crystal = New CRAXDDRT.Application
    MsgBox "Setting New Crytal Object - Done"
    Set Report = crystal.OpenReport(gszRptFileLoc + "\" + Trim(szReportName), 0)
    MsgBox "Opened Report" & gszRptFileLoc & "\" & Trim(szReportName)
    Report.DiscardSavedData
    Report.Database.SetDataSource rs
   
    MsgBox "Setting Crystal ReportViewer "
    CrystalActiveXReportViewer1.ReportSource = Report
    MsgBox "Setting Export Options 1"
    Report.ExportOptions.DestinationType = crEDTDiskFile
    Report.ExportOptions.FormatType = crEFTPortableDocFormat
    Report.DisplayProgressDialog = False
    MsgBox "Setting Export Options 1 - Done"
   
   
    If szReportName = "LB.rpt" Then
        gszRptFileLoc = gszRptFileLoc + "\B"
    'Tcs change begins - 07/19/2005
    ElseIf szReportName = "PerInf.rpt" Then
        gszRptFileLoc = gszRptFileLoc + "\Inf"
    ElseIf szReportName = "PerInf_ErrRpt.rpt" Then
        gszRptFileLoc = gszRptFileLoc + "\Inf"
    Else
    'Tcs change ends - 07/19/2005
       gszRptFileLoc = gszRptFileLoc + "\L"
    End If
     MsgBox gszRptFileLoc
       
    If Len(Trim(Str$(szBrkStr))) = 1 Then
        'Tcs change begins - 07/19/2005
        If szReportName = "PerInf.rpt" _
            Or szReportName = "PerInf_ErrRpt.rpt" Then
            Report.ExportOptions.DiskFileName = gszRptFileLoc + "\PERIINFL" + szRptCode + "_" + Mid(szRunDate, 1, 2) + Mid(szRunDate, 4, 2) + Mid(szRunDate, 7, 4) + "_0" + Trim(Str$(szBrkStr)) + ".PDF"
        Else
            Report.ExportOptions.DiskFileName = gszRptFileLoc + "\" + szRptCode + "_" + Mid(szRunDate, 1, 2) + Mid(szRunDate, 4, 2) + Mid(szRunDate, 7, 4) + "_0" + Trim(Str$(szBrkStr)) + ".PDF"
        End If
        'Tcs change ends - 07/19/2005
    Else
        'Tcs change begins - 07/19/2005
        If szReportName = "PerInf.rpt" _
            Or szReportName = "PerInf_ErrRpt.rpt" Then
            Report.ExportOptions.DiskFileName = gszRptFileLoc + "\PERIINFL" + szRptCode + "_" + Mid(szRunDate, 1, 2) + Mid(szRunDate, 4, 2) + Mid(szRunDate, 7, 4) + "_" + Trim(Str$(szBrkStr)) + ".PDF"
        Else
            Report.ExportOptions.DiskFileName = gszRptFileLoc + "\" + szRptCode + "_" + Mid(szRunDate, 1, 2) + Mid(szRunDate, 4, 2) + Mid(szRunDate, 7, 4) + "_" + Trim(Str$(szBrkStr)) + ".PDF"
        End If
        'Tcs change ends - 07/19/2005
    End If
    MsgBox "Set Disk File Name"
       
   
    If szBrkStr = szBrkEnd Then
        If szBrkStr = 1 Then
            Report.ExportOptions.PDFExportAllPages = True
        Else
            Report.ExportOptions.PDFExportAllPages = False
            Report.ExportOptions.PDFFirstPageNumber = ((szBrkStr - 1) * 4000) + 1
            Report.ExportOptions.PDFLastPageNumber = szPageCnt * 2 + 2
        End If
           
    Else
        If szBrkStr = 1 Then
            Report.ExportOptions.PDFExportAllPages = False
            Report.ExportOptions.PDFFirstPageNumber = ((szBrkStr - 1) * 4000) + 1
            Report.ExportOptions.PDFLastPageNumber = ((szBrkStr - 1) * 4000) + 4000
        Else
            Report.ExportOptions.PDFExportAllPages = False
            Report.ExportOptions.PDFFirstPageNumber = ((szBrkStr - 1) * 4000) + 1
            Report.ExportOptions.PDFLastPageNumber = ((szBrkStr - 1) * 4000) + 4000
        End If
     End If
    MsgBox "Set report option 2 - Done"
    MsgBox "Before Export" ' Fails after this step
    Report.Export (False)
    MsgBox "After Export"

    If Not cSetPrinter.SetPrinterAsDefault(sPrnName) Then
        If WriteFileRow(iFileNum, "Error Setting up the Milville printer as default") = False Then GoTo Do_CrystalErr
        End
    End If
    MsgBox "Printer Set"

    MsgBox "PDF Path to be set"
    sPDFPath = Report.ExportOptions.DiskFileName
    MsgBox "PDF path set"
    iRetval = PrintPDFs(iFileNum, sPrnName, sPDFPath)
    MsgBox "made PDF"

    sPrnName = cSetPrinter.m_sPrevPrinterDevName
    If Not cSetPrinter.SetPrinterAsDefault(sPrnName) Then
       If WriteFileRow(iFileNum, "Error reverting the old printer as default") = False Then GoTo Do_CrystalErr
       End
    End If
   
    rs.Close
    conn.Close
    DO_Crystal = FnReturnValue.success
    Set conn = Nothing
    Set crystal = Nothing
    Set Report = Nothing
    Set rs = Nothing
Exit Function

Do_CrystalErr:
WriteFileRow iFileNum, CStr(Err.Number) + " - " + CStr(Err.Description) + " - Source : DO_Crystal "
Exit Function

Err_handler:
MsgBox Err.Number & vbCrLf & Err.Description

End Function

[+][-]10/17/05 02:31 PM, ID: 15103316Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]10/17/05 02:33 PM, ID: 15103328Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]10/17/05 02:43 PM, ID: 15103390Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]10/17/05 04:22 PM, ID: 15103837Accepted Solution

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

About this solution

Zone: Crystal Reports Software
Tags: function, access
Sign Up Now!
Solution Provided By: mlmcc
Participating Experts: 2
Solution Grade: A
 
[+][-]10/18/05 06:42 AM, ID: 15107285Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]10/18/05 08:01 PM, ID: 15113187Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]10/19/05 06:01 AM, ID: 15115397Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]10/19/05 06:30 AM, ID: 15115617Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]10/19/05 08:32 PM, ID: 15121556Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]10/20/05 05:53 AM, ID: 15123784Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]10/20/05 02:26 PM, ID: 15128750Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]10/20/05 08:59 PM, ID: 15130383Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]12/28/05 08:03 PM, ID: 15568425Administrative Comment

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 30-day free trial to view this Administrative Comment or ask the Experts your question.

 
[+][-]12/29/05 09:50 AM, ID: 15572041Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]12/29/05 07:07 PM, ID: 15575497Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20091111-EE-VQP-89