PDA

Click to See Complete Forum and Search --> : Datareport object


madgoose
Dec 6th, 2006, 07:33 AM
If chkExport.Value = 1 Then
ExportToExcel rsRecordSet
ElseIf RptName2.Text = "Installation List" Then
dr1.DataMember = rsRecordSet.DataMember
dr1.Show
ElseIf RptName2.Text = "Sales List" Then
dr2.DataMember = rsRecordSet.DataMember
dr2.Show
End If

is there a way to create a datareport object like so?
Dim rtp as new datareport
set rpt = dr1

when doing this i cannot show the report. i must use dr1.show. dr1 is a datareport.

leinad31
Dec 6th, 2006, 09:32 AM
Yes you can, but you have to set the DataSource property first

rpt.Show vbModal


Check out these related threads
http://www.vbforums.com/showthread.php?t=439868&highlight=data+report
http://www.vbforums.com/showthread.php?t=433765

madgoose
Dec 6th, 2006, 11:48 AM
rpt.show vbmodal give an error. data member not found.
Select Case rptName
Case "Installation List"
sql = "Select [Job Number], [Booked Date], [Product Code] , [Capacity], [Value], [Job Name] , [Jobsite City] , [Jobsite State] , [Representative] , [Engineer Firm Name] from [Installation List] Where " & scode 'combinded sql statement
If chkSort(0).Value = 1 Then sql = sql & "Order by [" & cboField(3).Text & "]"
rsRecordSet.Open sql, Cn, adOpenStatic, adLockOptimistic
If rsRecordSet.EOF = True Then GoTo exit_routine
'Set dr1.DataSource = rsRecordSet
Set rpt.DataSource = rsRecordSet
Case "Sales List"
sql = "Select [Job Number], [Product Code] , [Capacity], [Job Name] , [Jobsite City] , [Jobsite State] ,[End User Name], [End User Phone] from [Installation List] Where " & scode 'combinded sql statement
If chkSort(0).Value = 1 Then sql = sql & "Order by [" & cboField(3).Text & "]"
rsRecordSet.Open sql, Cn, adOpenStatic, adLockOptimistic
If rsRecordSet.EOF = True Then GoTo exit_routine
'Set dr2.DataSource = rsRecordSet
Set rpt.DataSource = rsRecordSet
End Select

If chkExport.Value = 1 Then
ExportToExcel rsRecordSet
ElseIf rptName = "Installation List" Then
rpt.DataMember = rsRecordSet.DataMember
rpt.Show vbModal *******************error here*********
' ElseIf rptName = "Sales List" Then
' dr2.DataMember = rsRecordSet.DataMember
' dr2.Show
End If

madgoose
Dec 6th, 2006, 11:51 AM
i should have said that i have more than 1 datareport and i'm trying to simplify my code.

leinad31
Dec 6th, 2006, 08:25 PM
Did you set rpt to reference an existing report before setting the datasource and other code? Your original post made me assume you already did

Dim rtp as new datareport
set rpt = dr1

Hack
Dec 7th, 2006, 06:04 AM
Moved to reporting section