choosing (crystal) report at runtime

04-18-2004, 11:58 AM
I have 2 (or more) reports which the user can chose from.

I need to allow the user at runtime chose which report to print.

currently I define the report using:

Dim Report As New CRPQuestion

I tried

If UserReport1 = True then
Dim Report As New CRPQuestion
Dim Report As New CRPQuestion2
End If

This fails to even run as you cannot declare the same variable (report) twice in the same procedure.

Any suggestions?


04-18-2004, 01:41 PM
Dim Report As New CRPQuestion???
what is CRPQuestion? How it work?

Guy, try this:
If (option1.value = true) then
Set Report1 = crxApp.OpenReport(App.Path & "\ReportName.rpt")
elseif (Option2.value = true) then
Set Report1 = crxApp.OpenReport(App.Path & "\ReportName2.rpt")
.... and so on.
end if


Hope it work. Have fun

04-19-2004, 07:12 AM
Basically, it becomes a matter of scope. You need ONE CRAXDRT report object, or one new instance of the new DSR object, see below:

Public Sub Form_Load()

If Option1.Value = True Then
Dim myReport as CRReport1
Set myReport = New CRReport1
'continue code
Dim myReport as CRReport2
Set myReport = New CRReport2
'continue code
End If

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum