I was able to successfully Script the Crystal Component Version 6.0 with the
following:
Dim CRA
Dim CR
Set CRA = CreateObject("Crystal.CRPE.Application")
Set CR = CRA.OpenReport("TestRep.rpt")
CR.RecordSelectionFormula = "{CUSTOMER.CUSTOMER ID} in 5 to 20"
CR.ReadRecords
CR.Preview
msgbox "Press Ok To Close Preview"
Set CRA = Nothing
Set CR = Nothing
The Details. I was unable to do this with RBase or Access 2000. The report
was based on an Access 97 DB. Apparently the Crystal Drivers for this
version don't talk to the RBase driver or the Access 2000 Driver. I got the
same error on both of them "Unable to find Sql Server". There was a great
deal of this error mentioned at Crystal web site, but for my purposes,
upgrading to 8.5 just to prove it can easily be done for $188 wasn't worth
it. If you called this script from RBase and you wanted to change the
selection range of the report you would pass in the string value for the
RecordSelectionFormula. The command line for this woult look like (From
RBase):
Zip WScript.exe NameOfScript.VBS "{CUSTOMER.CUSTOMER ID} in 5 to 20"
The parameter value has to have Quotes because of the spaces in the
parameter. Then you would change the Script to Look Like This:
Dim CRA
Dim CR
Dim Rsf
Set CRA = CreateObject("Crystal.CRPE.Application")
Set CR = CRA.OpenReport("TestRep.rpt")
With Wscript
If .Arguments.Count < 1 Then
MsgBox "Missing Command Line Argument", vbOKOnly, "Error"
CallItQuits
End If
Rsf = .Arguments(0)
End With
CR.RecordSelectionFormula = Rsf
CR.ReadRecords
CR.Preview
msgbox "Press Ok To Close Preview"
CallItQuits
Private Sub CallItQuits()
Set CRA = Nothing
Set CR = Nothing
MsgBox "Processing Completed"
Wscript.Quit()
End Sub