access 2007 and crystal reports 8

Posted on 2011-10-28
Last Modified: 2012-05-12
Is there any way to have a command button from microsoft access(2007) launch a crystal report8.  I tried the shell command did not work. It only opened the crystal product did not launch the report.
Question by:centralmike
    LVL 28

    Expert Comment

    Don't have crystal to try, but I expect you could create a batch file to open the report, then fire that with Access.

    Chris B
    LVL 100

    Accepted Solution

    You have to use the viewer inside Access or call a third-party tool

    Is this Crystal 8 or Crystal 2008 you are using?


    Author Comment

    I am usine crystal 2008
    LVL 100

    Expert Comment

    I don't believe CR2008 can be called from Access.  CR2008 only supports a .Net interface.

    You will have to use an application that can be called from Access to produce the reports.

    LVL 21
    What I have learned is that in CR 2008 there is no RDC.  The RDC object model has been retired. This means you can no longer use it with VBA.   The recommended/suggested migration path is to use the Crystal Reports .NET SDK.  
    LVL 21
    I did find this VBScript that you may be able to use:

    Dim App, RptFile, User, Comp, Pw, Dest, RptSelect
    Dim Rept, Login, ExportFile, ParamFields, Year
    ' **** SET VARIABLES ********************************************************************************
    'Report File: Change to the full path and file name
    RptFile = "<full_path_to_report.rpt>"
    'Export File: Change to the full path and file name
    ExportFile = "<full_path_to_export_file.csv>"
    'Login Info, you may want to setup a dummy user for all of this.
    User = "user"
    Comp = "company"
    PW = "password"
    'Destination Export, Print or Preview - set it to 2 to Export, 1 to Print
    Dest = 2
    Set App = CreateObject ("CrystalRuntime.Application")
    Set Rept = App.OpenReport (RptFile)
    Login = App.LogOnServerEx("p2sodbc.dll", "<YOUR_DSN_NAME>", , , , , "DSN=<YOUR_DSN_NAME>; UID="+User+"; PWD="+PW+"; Company="+Comp)
    ' **** SET EXPORT OPTIONS ********************************************************************************
    'crEFTNoFormat 0
    'crEFTCrystalReport 1
    'crEFTDataInterchange 2
    'crEFTRecordStyle 3
    'crEFTRichText 4
    'crEFTCommaSeparated-Values 5
    'crEFTTabSeparatedValues 6
    'crEFTCharSeparatedValues 7
    'crEFTText 8
    'crEFTTabSeparatedText 9
    'crEFTPaginatedText 10
    'crEFTLotus123WKS 11
    'crEFTLotus123WK1 12
    'crEFTLotus123WK3 13
    'crEFTWordForDOS 15
    'crEFTQuattroPro50 17
    'crEFTExcel21 18
    'crEFTExcel30 19
    'crEFTExcel40 20
    'crEFTExcel50 21
    'crEFTExcel50Tabular 22
    'ODBC not permitted 23
    'crEFTHTML32Standard 24
    'crEFTExplorer32Extend 25
    'crEFTNetScape20 26
    Rept.ExportOptions.DiskFileName = ExportFile
    Rept.ExportOptions.DestinationType = 1
    Rept.ExportOptions.FormatType = 5 ' 5 IS FOR COMMA-SEPARATED FORMAT
    Rept.ExportOptions.CharFieldDelimiter = ""
    Rept.ExportOptions.CharStringDelimiter = ""
    ' **** HANDLE USER INPUT AND REPORT PARAMETERS **********************************************************
    'batchNumber= UserInput( "Enter Batch Number" )
    'WScript.Echo "You entered: " & batchNumber
    'beginInvNumber= UserInput( "Enter Beginning Invoice Number" )
    'WScript.Echo "You entered: " & beginInvNumber
    'endInvNumber= UserInput( "Enter EndingInvoice Number" )
    'WScript.Echo "You entered: " & endInvNumber
    Rept.ParameterFields.GetItemByName("BatchNo").AddCurrentvalue UserInput( "Enter Batch Number" )
    Rept.ParameterFields.GetItemByName("BegInvNbr").AddCurrentvalue UserInput( "Enter Beginning Invoice Number" )
    Rept.ParameterFields.GetItemByName("EndInvNbr").AddCurrentvalue UserInput( "Enter EndingInvoice Number" )
    ' **** FINALIZE OPTIONS **********************************************************
    If Not IsNull(Rept.ReportTitle) then
    RptWindow = Rept.ReportTitle
    RptWindow "Crystal Reports"
    end If
    If Dest = 1 then
    End If
    If Dest = 2 Then
    End If
    ' **** AWAY WE GO **********************************************************
    set WshShell = WScript.CreateObject("WScript.Shell")
    While WshShell.AppActivate(RptWindow) = TRUE
    wscript.sleep 10000
    Set WshShell=Nothing
    Set Rept=Nothing
    Set App=Nothing 
    WScript.Echo "Invoice Export Process Completed"
    ' **** FUNCTIONS SECTION ****************************************************************************************
    Function UserInput( myPrompt )
    ' This function prompts the user for some input.
    ' When the script runs in CSCRIPT.EXE, StdIn is used,
    ' otherwise the VBScript InputBox( ) function is used.
    ' myPrompt is the the text used to prompt the user for input.
    ' The function returns the input typed either on StdIn or in InputBox( ).
    ' Check if the script runs in CSCRIPT.EXE
    If UCase( Right( WScript.FullName, 12 ) ) = "\CSCRIPT.EXE" Then
    ' If so, use StdIn and StdOut
    WScript.StdOut.Write myPrompt & " "
    UserInput = WScript.StdIn.ReadLine
    ' If not, use InputBox( )
    UserInput = InputBox( myPrompt )
    End If
    End Function 

    Open in new window


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Many companies are making the switch from Microsoft to Google Apps ( Use this article to learn more about what Google Apps has to offer and to help if you’re planning on migrating to Google Apps. It is …
    User Beware!  This is a rather permanent solution to removing your email from an exchange server.  The only way to truly go back is to have your exchange administrator restore your mailbox from backups.  This is usually the option of last resort.  A…
    The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…
    The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …

    761 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now