cotano
asked on
DataReport with recordset
I want to create a report using the VB DataReport generator. This report should be bound to a recordset, and not bound to the database directly. Also, I want to assign the recordset at run-time, because the same report will be used to print multiple recordsets. How do I do this?
See this link: http://support.microsoft.com/support/kb/articles/Q190/4/11.ASP?LN=EN-US&SD=gn&FR=0
If you want to use the same report for multiple records, i think all of the recordset need to have same fields/columns.
Try this one.
-------------------------- ---------- ---------- ---------- -
Sub PrintAllRecords()
Dim TConnection As ADODB.Connection
Dim TRECORDSET As ADODB.Recordset
' Set a new connection to ODBC
Set TConnection = New ADODB.Connection
' Open the DSN file, which is add in ODBC - User DSN
TConnection.Open "DSN=Your DSN"
' Set a SQL command
StrSQL = "SELECT CardNo,Name,Address FROM WHOLELIFE"
' Execute the SQL command and retrieve all records into
' TRecordset
Set TRECORDSET = TConnection.Execute(StrSQL )
' Set the record source for the report.
Set ListAllWholeLife.DataSourc e = TRECORDSET
ListAllWholeLife.Show
End Sub
-------------------------- ---------- ---------- ---------- -
Try this one.
--------------------------
Sub PrintAllRecords()
Dim TConnection As ADODB.Connection
Dim TRECORDSET As ADODB.Recordset
' Set a new connection to ODBC
Set TConnection = New ADODB.Connection
' Open the DSN file, which is add in ODBC - User DSN
TConnection.Open "DSN=Your DSN"
' Set a SQL command
StrSQL = "SELECT CardNo,Name,Address FROM WHOLELIFE"
' Execute the SQL command and retrieve all records into
' TRecordset
Set TRECORDSET = TConnection.Execute(StrSQL
' Set the record source for the report.
Set ListAllWholeLife.DataSourc
ListAllWholeLife.Show
End Sub
--------------------------
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Here is my code :
with rptProgressReport
set .datasource = rsWeight
.datamember = ""
with .sections("PageHeader")
.item(1).caption = "Date"
.item(2).caption = "Kg"
.item(3).caption = "lbs"
end with
with .sections("Detail")
.item(1).datafield = "MeasureDate"
.item(2).datafield = "Value"
.item(3).datafield = "Value2"
endif
.refresh
.show
end with
The problem is that I always get this error :
DataField('Empty') not found.
And my report is empty when it appears.
What causes this, and how can I fix it? I really need help...
with rptProgressReport
set .datasource = rsWeight
.datamember = ""
with .sections("PageHeader")
.item(1).caption = "Date"
.item(2).caption = "Kg"
.item(3).caption = "lbs"
end with
with .sections("Detail")
.item(1).datafield = "MeasureDate"
.item(2).datafield = "Value"
.item(3).datafield = "Value2"
endif
.refresh
.show
end with
The problem is that I always get this error :
DataField('Empty') not found.
And my report is empty when it appears.
What causes this, and how can I fix it? I really need help...
before using .item(x).datafield to any value assign that item DataMember as
..Item(x).DataMember = ""
and please check the type of the control..
basically have a look at the sample program given above by me .. I think that will help u in undersatnding more things..
Hope this helps u...
..Item(x).DataMember = ""
and please check the type of the control..
basically have a look at the sample program given above by me .. I think that will help u in undersatnding more things..
Hope this helps u...