Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

STill new at this

Status
Not open for further replies.

RGoldthorpe

Technical User
Aug 10, 2001
83
0
0
GB
Can somebody give me some clue on how to open any crystal report in the CRviewer.

I.E A button that you use to select the report to view in crviewer.

I am totally stumped.

Thats not new really but all help is recieved very gratefully

Thanks

Rachel[ponder]
 
if you are using Crystal Report ActiveX Designer this code will help you

add CrViewer Control to your form
your report name (MyCrystalReport)
'---------------------------------------
CRViewer1.ReportSource = MyCrystalReport
CRViewer1.ViewReport
'--------------------------------------

hope this will help you
 
Thanks

I probably did explain very well what I was after

This is what I have done already this works for one fixed report in the viewer (right?? I might be wrong)

What I want to be able to do is the user select a report to look at in the veiwer from a list.

Could you help me again please

ThanX in advance

Rachel
 
Dear RGold

if your reports have been created using crystal report activeX designer
-add listbox to your form
-add list of items mentioned to reports
-use if to choose the correct report

I.E.
'-------------------
Public Sub ReportSelection()
If Listbox1.listindex=0 then
CRViewer1.ReportSource = MyCrystalReport
CRViewer1.ViewReport
elseif listbox1.listindex=1 then
CRViewer1.ReportSource = MyCrystalReport2
CRViewer1.ViewReport
End if
End Sub

I hope that I got your point
 
I dont think its you I think its me.

Thats just what I wanted

Can I view rpts reports that were created in crystal reports using this viewer or only activeX ones?
 
hmmmmmm

if your crystal reports are created in crystal software SO you have to use CrystalReport activeX contorl (CRYSTL32.DLL)
This Ocx will do that just follow this steps
1- add crystl32.dll to your form
2-if you want to preview the report before printing it set the destination property=(0-crptToWindow)
(1-rptToPrinter) if you aim to print it directly
3-copy this code
'-------------------
Public Sub ReportSelection()
If Listbox1.listindex=0 then
crystalreport.ReportFileName = "your report file1 path"
crystalreport.printreport
elseif listbox1.listindex=1 then
crystalreport.ReportFileName = "your report file2 path"
crystalreport.printreport
End if
End Sub
'----------------------
hope your problem has been solved
if you got any problem just email me and I will send you source code


 
Thanks your Brill I have sorted what I wanted it to do now.

thanks for all your time it is really appreciated.

here is my code.

Dim crApp As New CRAXDRT.Application
Dim crRep As CRAXDRT.Report
Dim MyReport As String
Dim OldDefaultPrinter As String

Private Declare Function WriteProfileString Lib "kernel32" _
Alias _
"WriteProfileStringA" _
(ByVal lpszSection As String, _
ByVal lpszKeyName As String, ByVal lpszString As String) As Long

Private Declare Function SendMessageTimeout Lib "user32" Alias _
"SendMessageTimeoutA" (ByVal hwnd As String, ByVal _
msg As String, ByVal wParam As String, ByVal lParam _
As String, ByVal fuFlags As String, ByVal uTimeout As _
String, lpdwResult As String) As String

Private Sub cmdOpenCrystalReport_Click()

' load a standalone report created in the designer
Set crRep = crApp.OpenReport(File1.Path & "\" & MyReport)
CRViewer91.EnableExportButton = True
CRViewer91.ReportSource = crRep
crRep.VerifyOnEveryPrint = True
'crRep.RecordSelectionFormula = "{MyTable.MyField} = 'test';"
' print preview

CRViewer91.ViewReport

End Sub

Private Sub print_click()
'Save default printersettings.
OldDefaultPrinter = Printer.DeviceName & "," & Printer.DeviceName & "," & Printer.Port
'Show windows Printers
On Error GoTo Cancel:
ComDlg1.ShowPrinter
'Printer the Crystal Report out using viewer print options
CRViewer91.PrintReport
' Calls the Kernel32 to set back default printer
Call WriteProfileString("windows", "device", OldDefaultPrinter)
Call SendMessageTimeout(HWND_BROADCAST, WM_WININICHANGE, 0, "windows", SMTO_NORMAL, 1000, 0)
Cancel: MsgBox "it not working"
End Sub

Private Sub Drive1_Change()
Dir1.Path = Drive1.Drive
End Sub
Private Sub Dir1_Change()
File1.Path = Dir1.Path
End Sub
Private Sub File1_Click()
MyReport = File1.FileName
End Sub

Private Sub Form_Load()
Screen.MousePointer = vbHourglass
Screen.MousePointer = vbDefault
End Sub
Private Sub Form_Resize()
CRViewer91.Top = 0
CRViewer91.Left = 0
CRViewer91.Height = ScaleHeight
CRViewer91.Width = 7500
End Sub

Could somebody tell me why the heck I manage to get everything sorted out and then my printing just stops working???

Its enought o drive a girl to tears.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top