Extract to CR two recordsets
Hi:
I have this code for extract a recordset to CR:
Code:
Set db = Workspaces(0).OpenDatabase(caminho)
Sql = _
"select" & _
" nomecomprador, expositor, gaiola" & _
" from talao2006" & _
" order by nomecomprador"
Set rs = db.OpenRecordset(Sql)
Set Data1.Recordset = rs
Set Report = New CRAXDRT.Application
Set Rpt = Report.OpenReport(App.Path & "\aves2.rpt")
If (Rpt.HasSavedData) Then Rpt.DiscardSavedData
Rpt.Database.SetDataSource rs, 3, 1
setviewersize
CRViewer1.ReportSource = Rpt
CRViewer1.ViewReport
But Now I need to extract annother recordset to the same Report...
Something like this:
Code:
Set db = Workspaces(0).OpenDatabase(caminho)
Sql = _
"select" & _
" nomecomprador, expositor, gaiola" & _
" from talao2006" & _
" order by nomecomprador"
Set rs = db.OpenRecordset(Sql)
Set Data1.Recordset = rs
Sql = _
"select" & _
" nomecomprador, expositor, gaiola" & _
" from talao2007" & _
" order by nomecomprador"
Set rs = db.OpenRecordset(Sql)
Set Data1.Recordset = rs
Set Report = New CRAXDRT.Application
Set Rpt = Report.OpenReport(App.Path & "\aves2.rpt")
If (Rpt.HasSavedData) Then Rpt.DiscardSavedData
Rpt.Database.SetDataSource rs, 3
setviewersize
CRViewer1.ReportSource = Rpt
CRViewer1.ViewReport
Off course The report only show one recordset...
Anyone know the way to do this?
Thanks
Re: Extract to CR two recordsets
Are you trying to display records from two tables
Re: Extract to CR two recordsets
In fact no...this is just a example...But I need make Diferents SQL's from the same table
Re: Extract to CR two recordsets
Quote:
Originally Posted by sacramento
In fact no...this is just a example...But I need make Diferents SQL's from the same table
hope you are going to retrive the same Fields. Then simply have an IF clause to determine when which SQL to be used.
Code:
Set db = Workspaces(0).OpenDatabase(caminho)
If YourCondition then
Sql = _
"select" & _
" nomecomprador, expositor, gaiola" & _
" from talao2006" & _
" order by nomecomprador"
Else
Sql = _
"select" & _
" nomecomprador, expositor, gaiola" & _
" from talao2006" & _
" order by nomecomprador"
End If
Set rs = db.OpenRecordset(Sql)
Set Data1.Recordset = rs
Set Report = New CRAXDRT.Application
Set Rpt = Report.OpenReport(App.Path & "\aves2.rpt")
If (Rpt.HasSavedData) Then Rpt.DiscardSavedData
Rpt.Database.SetDataSource rs, 3, 1
setviewersize
CRViewer1.ReportSource = Rpt
CRViewer1.ViewReport
Have I somewhere lost your main question??!
Re: Extract to CR two recordsets
Hi:
No I don't want a If Else condition...I want Print in the Report the two Sql conditions at the same time in the same report...
Re: Extract to CR two recordsets
Quote:
I want Print in the Report the two Sql conditions
you mean a set of data satisfying both the SQL statements??
Then simply structure your SQL accordingly.
eg let's assume there is a SQL2 which selects a few sets of records from Table2, Pass this resulting records into SQL1 which further selects/filters based on records from the list by comparing records in Table1.
Re: Extract to CR two recordsets
Sory...but Wicht way I can do this in SQL?
Re: Extract to CR two recordsets
maybe by this way no?:
Code:
Sql = _
"select" & _
" nomecomprador, expositor, gaiola" & _
" from talao2006" & _
" order by nomecomprador UNION ALL " & _
"select" & _
" nomecomprador, expositor, gaiola" & _
" from talao2007" & _
" order by nomecomprador"