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

Problem Changing Data Source at runtime for Crystal Report

Status
Not open for further replies.

taranis

Programmer
Jan 31, 2001
20
0
0
US
I'm using VB6 and Crystal 8 and Access 97 to display a report. I want to change the data source at runtime. When I try to do this I get the following error "Data Source name too long". I changed the path and name of the Data Suurce name so that it was 8 characters long and I still get the same error.

I am new to Crystal reports for the most part so I am probably doing something stupid. The report was working fine in the project but it used the crystal API's. I now want to use the Cyrstal Designer that comes with version 8.



Source code is shown below:
Note: The rs is returning a valid record set and contains all of the displayed fields in the Report.



Private Report As New CrystalReport1
Private rs As New adoDB.Recordset
Private db As New adoDB.Connection

Private Sub Form_Load()

Dim strSQL As String
Screen.MousePointer = vbHourglass
strSQL = "SELECT Imex.DataFileType, Imex.Description,Imex_Log.ImexLogId,Imex_Log.ImexName,Imex_log.DataFile,Imex_log.DataFileDateTime,Imex_Log.StartDateTime,Imex_Log.EndDateTime,Imex_log.UserId," _ & "Imex_log.Comments,Imex_Report.ReportId,Imex_Report.ReportText FROM (ImEx_Log INNER JOIN ImEx_Report ON ImEx_Log.ImExLogID = ImEx_Report.ImExLogID) INNER JOIN ImEx " _
& "ON ImEx_Log.ImExName = ImEx.ImExName where IMEX_Log.IMEXLOGID =" & frmImExLogs.LOGID

db.Open "Provider=Microsoft.Jet.OLEDB.3.51;Data Source=C:\Program Files\Microsoft Visual Studio\Projects\IMEX_E_Working\IMEX_NEW_GE1.MDB"
rs.Open strSQL, db, adOpenKeyset, adLockBatchOptimistic

Report.Database.SetDataSource rs
CRViewer1.ReportSource = Report
CRViewer1.ViewReport
Screen.MousePointer = vbDefault
End Sub
 
Try replacing
Report.Database.SetDataSource rs
With either
Report.Database.Tables(1).SetDataSource rs
Or
Report.Database.Tables(1).SetDataSource rs, 3

I can't remember off the top of my head whether or not you need the 3. I believe the second argument is DataTag and a 3 tells Crystal it is an ado recordset.

Ruairi

Could your manufacturing facility benefit from real time process monitoring? Would you like your employees to be able to see up to the minute goal and actual production?
For innovative, low cost solutions check out my website.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top