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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Blank Report

Status
Not open for further replies.

tathagat

Programmer
Jan 29, 2002
5
US
Hi everyone,
I am new to this and trying to generate cystal report dynamically. I am using ttx file and record set for data source. I am not getting any error but not getting anything in report alos, it's blank. I am using subreport in my mail report and that subreport is also create by same rs (same columns and reocrds).
Here is my code..please do advice....
Thanks.
------------------------------------------------------
Private Sub Form_Load()

Dim conn As New ADODB.Connection 'CONNECTION TO BROKER QUERIES
Dim rs As New ADODB.Recordset

Dim appn As New CRAXDRT.Application
Dim rpt As New CRAXDRT.Report

CRViewer1.DisplayBorder = True 'MAKES REPORT FILL ENTIRE FORM
CRViewer1.DisplayTabs = False 'THIS REPORT DOES NOT DRILL DOWN, NOT NEEDED
CRViewer1.EnableDrillDown = False 'REPORT DOES NOT SUPPORT DRILL-DOWN
CRViewer1.EnableRefreshButton = False 'ADO RECORDSET WILL NOT CHANGE, NOT NEEDED
Do While CRViewer1.IsBusy 'ZOOM METHOD DOES NOT WORK WHILE
DoEvents 'REPORT IS LOADING, SO WE MUST PAUSE
Loop
Dim sConnectStr As String
Dim sid, user, passwd As String
sid = "shrd"
user = "tdwived"
passwd = "tdwived"
On Error GoTo ErrorHandler

sConnectStr = "Provider=MSDAORA;Data Source= " & sid & ";User ID=" & user & ";Password=" & passwd & ""
conn.CursorLocation = adUseClient
conn.CommandTimeout = 200

conn.Open sConnectStr
MsgBox "connected"
rs.Open &quot;SELECT ASSET_SEQ_ID,ASSET_STATUS_CODE FROM ASSET WHERE rownum <=2&quot;, conn ', adOpenStatic, adLockReadOnly

Set rpt = appn.OpenReport(&quot;C:\Project\Rms\Release\Feb-2004\Crystal Report\CrystalReportWithDdtFile.rpt&quot;)
MsgBox rs.Fields(1).Value
'rpt.Database.Tables.Item(1).SetLogOnInfo &quot;SHRD.RFC.COM&quot;, &quot;&quot;, &quot;TDWIVED&quot;, &quot;TDWIVED&quot;

'rpt.Database.Tables(1).SetLogOnInfo &quot;&quot;, &quot;shrd&quot;, &quot;tdwived&quot;, &quot;tdwived&quot;

'rpt.DiscardSavedData
rpt.Database.SetDataSource rs, 3, 1
CRViewer1.ReportSource = rpt

CRViewer1.ViewReport

Do While CRViewer1.IsBusy 'ZOOM METHOD DOES NOT WORK WHILE
DoEvents 'REPORT IS LOADING, SO WE MUST PAUSE
Loop 'WHILE REPORT LOADS.

CRViewer1.Zoom (100)
'CRViewer1.PrintReport
'CRViewer1.Visible = True

rs.Close 'ALL BELOW HERE IS CLEANUP
Set rs = Nothing

conn.Close
Set conn = Nothing
' -----------
Exit Sub
ErrorHandler:
MsgBox (Err.Number & &quot;:&quot; & Err.Description)
End Sub
 
When you use an ADO datasource, you need to add one line of code that you don't normally use when the report has its own connectivity to the database. After the line that uses the SetDataSource method, and before assigning the report as the ReportSource for the viewer, add the following line of code:

rpt.ReadRecords

You probably also should include the DiscardSavedData line you remarked out just as a matter of principle.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top