cancel
Showing results for 
Search instead for 
Did you mean: 

Print a Crystal Reports file from Access front-end using VBA

Former Member
0 Kudos

I need advice for printing a Crystal Reports file in a Microsoft Access front-end application using VBA since I am new with CR.

I'm using Crystal Reports Developer 2008 (version 12.5) and MS Access 2010 in a 32 bit environment. The Access front-end is distributed to about 30 Windows 7 and XP users running Access runtime version. I have successfully printed the file from Access in the computer where the CR Developer's edition is installed, but not so successful in printing the same file from the Access front-end users' computers.

The error I am getting from Access when trying to print the CR is "Error 5 - Invalid Procedure call or argument". This is usually related to a missing reference in MS Access. So there is something missing in the compiled front-end that is present in the CR Developer's computer. I also realized that even though all the front-end computers have installed Crystal Reports runtime, CR file format is not recognized and cannot be printed in those computers (as I said, I am new with CR).

Today I installed CR viewer in the CR developer's computer, but I could not install the Activex references to print within Access using VBA. Latter on I found this link in this online community:

I would really appreciate if someone can point me in the right direction in how to print a CR file from a front-end 2010 Access runtime using VBA.

Thanks in advance for your help,

Max

Accepted Solutions (1)

Accepted Solutions (1)

0 Kudos

Hi Max,

CR does not support VBA scripts any more because there is no ActiveX report engine component now.

As Ido indicated you would have to use a third party tool or write a Command line app or similar using the CR .NET Assemblies.

Answers (2)

Answers (2)

Former Member
0 Kudos

Ido and Don,

Thank you for answering my question. I appreciate your willing to help.

I will take the easiest approach to me which is to replicate the form in Access, so I can print directly without the need of further programming.

Best regards,

Max

ido_millet
Active Contributor
0 Kudos

If you don't have the time or experience to develop the Crystal runtime code and deploy the Crystal runtime, a simple alternative is to install a 3rd-party viewer that accepts command line calls to trigger viewing/printing/exporting.

For a list of 3rd-party Crystal Reports viewers, see: http://kenhamady.com/bookmarks.html#viewers

Here is sample vba code that works to call one of these viewers from an Access form, set the report (based on a combo box choice) and parameter value, and print the report:

__________________________________________________________________
Private Sub Combo0_AfterUpdate()
Dim rs As Object
Set rs = Me.Recordset.Clone
rs.FindFirst "[txtReportName] = '" & Me![Combo0] & "'"
If Not rs.EOF Then Me.Bookmark = rs.Bookmark

Dim myreport As String
Dim stAppName As String
Dim myvalret As String
' me.fullrep is a field that concatenates the report path and name
myreport = Me.fullrep
myvalret = Str(MyCaseno)
stAppName = "
C:\Program Files\Millet Software\DataLink Viewer 2011\DataLink_Viewer_2011.exe" & _
" -v """ & myreport & """ ""Parm1:" & myvalret & """ ""Printer:Default"""
DoCmd.Close
Call Shell(stAppName, 1)
End Sub
__________________________________________________________________