Hi, i’m trying to use DataReport with VB 6. But got Run-time error ’13’: Type mismatch. Here is my code:
Private Sub cmdGenerateReport_Click()
Dim conString As String
conString = “Provider=Microsoft.Jet.OLEDB.4.0;Data Source=” & App.Path & “\” & “Database.mdb;”
Set con = New ADODB.Connection
con.Open conString
Set rec = New ADODB.Recordset
query = “select name from ms_people”
rec.Open query, con, adOpenStatic, adLockOptimistic
If rec.RecordCount > 0 Then
Set DataReport1.DataSource = rec
DataReport1.Sections(“Section1”).Controls(“Text1”).DataField = “name”
DataReport1.Show
End If
rec.Close
End Sub
The code error at ‘Set DataReport1.DataSource = rec’.
DataReport1 is a simple data report (i didn’t change the attributes)
Any help would be very grateful >.<. Thanks