|
-
May 25th, 1999, 11:49 AM
#1
VB6 Data Report Problem--Need Help Fast
I posted the question about Crystal Reports below. Sorry for posting twice, but I just read elsewhere in this list that it is possible to use an existing ADO recordset as the data source for a VB6 DataReport, and then bind the report controls to the recordset fields. I tried
Set DataReport1.DataSource = [my recordset name]
but I keep getting the "Invalid Data Source"
message. Can anyone give me the code to do this with the Data Report?
Thanks,
John
-
May 25th, 1999, 11:59 AM
#2
Re: VB6 Data Report Problem--Need Help Fast
Hi John.
I had the same trouble. Try to do the following steps and i think it´ll work
1. Catch the error
On Error Resume NExt
2.And then bind the fields of your datareport with
the fields of your Recordset.
3. At last, refresh your report
Me.Refresh
Put the previous code in the event initialize of the DataReport.
It works for me. I´m working with ADODB Recordsets
filled calling a ADODB.Command.
If you don´t success, report me the trouble and i´ll try to help you, but be sure it works.
Hope it helps!
Bye
JaIme
-
May 25th, 1999, 02:07 PM
#3
Re: VB6 Data Report Problem--Need Help Fast
Here is the sample code for running reports with ADO recordsets. If you have any more question feel free to mail me. I have more stuff on how to develop grouping reports using ADO's and recordsets. My email Id is [email protected]
Good luck
The following code goes into the module:
option Explicit
public MyConn as ADODB.Connection
public myRec as ADODB.Recordset
public myRec1 as ADODB.Recordset
Sub main()
set myRec = new ADODB.Recordset
set myRec1 = new ADODB.Recordset
set MyConn = new ADODB.Connection
With MyConn
.Provider = "Microsoft.jet.oledb.3.51"
.Open "C:\Program Files\Microsoft Visual Studio\VB98\Biblio.mdb"
End With
myRec1.Open "SELECT * From Publishers ", MyConn, adOpenStatic, adLockOptimistic
Form1.Show
End Sub
The following code goes into the command1 click event
DataReport1.Visible = true
The following code goes into the report initialisation section:
private Sub DataReport_Initialize()
With DataReport1
set .DataSource = myRec1
.Sections.Item(3).Controls.Item(1).DataField = myRec1.Fields(0).Name
.Sections.Item(3).Controls.Item(2).DataField = myRec1.Fields(1).Name
End With
End Sub
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|