choosing (crystal) report at runtime

fshrago
04-18-2004, 12:58 PM
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
else
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?

Thanks

gchwee
04-18-2004, 02: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

Report1.DiscardSavedData
Report1.Printout

Hope it work. Have fun

MKoslof
04-19-2004, 08: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
Else
Dim myReport as CRReport2
Set myReport = New CRReport2
'continue code
End If

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum