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

HOW TO CUSTOMIZE DATA REPORTS IN RUN TIME?

Status
Not open for further replies.

Oliver76

Programmer
Oct 2, 2001
60
Dear Experts,

Im trying to make a program wherein the reports will be customized during run time. I'm using DataReport and DataEnvironment. Do I have to use other software?

Thanx a lot in advance....
 
DataEnvironment is not needed to fill the DataReport. You have to do more coding.

Set RptCustomers.DataSource = adoPrimaryRS
Note: RptCustomers is the name of my DataReport

With this you can send the adoPrimaryRS to the DataReport. Now use SQL to filter out what Data you want send.

Private Sub FillRpt()
Set RptCustomers.DataSource = adoPrimaryRS
End Sub


Private Sub CmdPrint_Click()
Set db = New Connection
db.CursorLocation = adUseClient
db.Open "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Program.mdb;Jet OLEDB:Database Password=1"
Set adoPrimaryRS = New Recordset
adoPrimaryRS.Open "select [ID],[First Name],[Last Name] from Customers where ID like" & "'" & "'" & Text1.text & "'" , db, adOpenStatic, adLockOptimistic
FillRpt
RptCustomers.Show

End Sub


Something like that???



 
Oliver

To change the data used by the datareport:

Use a SQL command in the dataenvironment (ie you enter a sql string).
Have the SQL for your standard report as the command string.
Design your report using the SQL command.
At run time change the SQL command string as required, ensuring that the returned field structure does not change.
Show the report.

A code snippet is shown below:

On Error Resume Next
de.rssqlR1_Grouping.Close
On Error GoTo EH
de.Commands("sqlR1_Grouping").CommandText = MakeR1SQL

de.sqlR1_Grouping
dR1.Refresh

de is data environment
sqlR1_Grouping is the command object in the data environment
dR1 is the data report


To change displayed labels etc. just reference them as you would controls on a form.

e.g.

dR1.Caption = R1TITLE
dR1.Title = R1TITLE
dR1.Sections("PageHeader").Controls("lTitle").Caption = R1TITLE
dR1.Sections("PageHeader").Controls("lScope").Caption = _
ScopeDates & ScopeUser & ScopeContent
dR1.Sections("ReportFooter").Controls("lUser").Caption = PrintedBy
dR1.Refresh

Make sure you have the lates Service Pack SP5 - or you can run into serious bugs.

Regards

sadcow
 
Thanx to you fastway and sadcow....i'll try your codes...:)
 
Thanx to you fastway and sadcow....i'll try your codes...:) By the way where can i get that "Service Pack SP5"?

Thanx again...
 
You can order it, or download it from the microsoft web site. If you order it, there is normally a small charge to cover their costs.

Sadcow
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top