Thanks in advance to all!
Would appreciate a quick response...
Thanks
Printable View
Thanks in advance to all!
Would appreciate a quick response...
Thanks
Add these references to to your project.
"Crystal Reports x.x ActiveX Designer Runtime Library"
"Crystal Data Object"
"Crystal Reports Expert"
"Crystal Reports x.x Library"
Then something like this to open the report and export the report as a .pdf file.
VB Code:
Option Explicit Private Function SendReport(ByVal sWhere As String) Dim oReport As CRAXDRT.Report Dim crxApplication As New CRAXDRT.Application Dim crxExportOptions As CRAXDRT.ExportOptions Set crxApplication = New CRAXDRT.Application Set oReport = crxApplication.OpenReport(App.Path & "\Report.rpt", 1) oReport.RecordSelectionFormula = sWhere Set crxExportOptions = oReport.ExportOptions crxExportOptions.DestinationType = crEDTDiskFile crxExportOptions.DiskFileName = App.Path & "Report " & Format(Now, "YYYY-MM-DD") & ".pdf" crxExportOptions.FormatType = crEFTPortableDocFormat crxExportOptions.PDFFirstPageNumber = 1 crxExportOptions.PDFLastPageNumber = 1 crxExportOptions.PDFExportAllPages = True oReport.Export False 'Terminate Cleanly Set oReport = Nothing Set crxApplication = Nothing Set crxExportOptions = Nothing End Function
Thanks a mil...
The .pdf is created in the path of the application...
which I later opened
Any way to open on the fly?
I suppose your could after the termination code use the file name
and shell Acrobat Reader with the file name as a parameter.
Thanks
I am shelling acrobar reader...
I don't see the .pdf on the screen...
I have to go to the taskbar ang maximize... it to see it at all
Any ideas? Can't I just pop it on top?
Thanks in advance...
To shell Acrobat or program associated with the .pdf extension use...
Let me know if this was what you were describing.VB Code:
Option Explicit Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, _ ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, _ ByVal nShowCmd As Long) As Long Const SW_SHOWNORMAL As Long = 1 Const SW_SHOWMAXIMIZED As Long = 3 Const SW_SHOWMINIMIZED As Long = 2 Private Sub cmdShellPDF_Click() 'WITH THE YOU CAN SET THE WORKING DIRECTORY TOO! ShellExecute Me.hwnd, vbNullString, "D:\Test.pdf", vbNullString, "D:\", SW_SHOWMAXIMIZED End Sub
Thanks much....
Your welcome.
Glad to help.
I have a table with two fields ActivityDate and Event
How do I pass a parameter to the crystal report so that
it displays events not greater than x number of days old only..
Currently, the report is showing all events
Thanks
Use the parameterfields of the oReport object. You need to clear
each parameter before you set a value to it, every time.
HTHCode:oReport.ParameterFields.Item(1).ClearCurrentValueAndRange
oReport.ParameterFields.Item(1).AddCurrentValue dActivityDate
oReport.ParameterFields.Item(2).ClearCurrentValueAndRange
oReport.ParameterFields.Item(2).AddCurrentValue sEvent
Bear with me
The report has subreports and is created external to VB
and I am exporting it into .pdf as u showed me and kick acrobat
to display it... Now, it is one of the subreborts for which I need
a parameter field... So the user could be prompted on the fly (if possible) to enter something and corresponding data would be displayed..
Do we add a parameter field to the individual report before
entering as a subreport...
I guess I am asking how does it all tie...together ?
Currently, my main report displays data for all organizations grouping them by OrgID then the subreport displays data just for the orgID being displayed.. But it's displaying all the activities for it since the beginning of time for the ORg.. What I'd like to do is to create a field that the client could enter a number like 30 enter and only last 30 days activity (for example) would be displayed..
I am probably verbose... But that happens when one has little time to do something with a new tool..
Thanks again
How does one refresh the report data frm within VB?
Thanks
Since the report is exported out as a pdf file, the report can not
be refreshed unless you re-export the report.
You may want to look at using the Crystal Report Viewer control
in VB to allow you to view/export the report in real time.
Although if you are distributing the program ther may be licensing issues.
As far as the previous post, you need to create a parameter at
the main report level. Then link the parameter to the subreport
by reimporting the sub report. This will allow you to pass a
parameter to the report which will inturn go to the sub report.
HTH
always...
Thanks..
For the previous post
Even ReExporting does not seem to do it.. I'll check again...
As for the prior post..
I have decided to create stored procedures which accept parameters that populate a table with the data that I need and the report or subreport would then extract from that table..
Actually, the export would work if one opts to not save the data with the report....
Thanks
In Crystal Reports, when you created the report, there is a
setting under File > Options > Reporting tab... called "Save data
withreport" checkbox. Uncheck it and resave your report. Also,
since you have a subreport, under the New Report tab there is
another checkbox to "Reimport subreport subreports when
opening reports". I'm not too sure if that is only for the
development enviroment or if it could affect your results.
HTH