Hi
I've set up DataReport from a DataEnviontment, Connection and Command objects.
The Command object is an SQL query which returns the correct fields to allow me to design the report.
At run time I amend the connection and Command (SQL query) details so user can specify different date ranges, etc.
All works OK.
However, I know need to run another query to then compare and amend the first query.
I thought I could add another Command under the same connection and then in VB6, use the 2 produced recordsets from within the DataEnvironment1.
this is my code...
With DataEnvironment1
'Set connection string for Access 97/2000 database
.Connection1.ConnectionString = CONNECTION_STRING_FOR_ACCESS
'Pass queries to data environment command objects
.Commands(1).CommandText = strQuery
.Commands(2).CommandText = strQuery2
'Set command types to query
.Commands(1).CommandType = adCmdText
.Commands(2).CommandType = adCmdText
End With
With DataReport1
'Set report orientation and open preview
.Orientation = rptOrientLandscape
.Show vbModal
End With
It's not until after the "With DataReport1" line that I can see the first recordset
i.e
Debug.Print DataEnvironment1.rscomQuery.RecordCount
but trying to do the same on the second query
Debug.Print DataEnvironment1.rscomQuery2.RecordCount
I get ...
Run Time Error 3704
Operation is not allowed when object is closed
any advice please?
Thanks
Wayne
I've set up DataReport from a DataEnviontment, Connection and Command objects.
The Command object is an SQL query which returns the correct fields to allow me to design the report.
At run time I amend the connection and Command (SQL query) details so user can specify different date ranges, etc.
All works OK.
However, I know need to run another query to then compare and amend the first query.
I thought I could add another Command under the same connection and then in VB6, use the 2 produced recordsets from within the DataEnvironment1.
this is my code...
With DataEnvironment1
'Set connection string for Access 97/2000 database
.Connection1.ConnectionString = CONNECTION_STRING_FOR_ACCESS
'Pass queries to data environment command objects
.Commands(1).CommandText = strQuery
.Commands(2).CommandText = strQuery2
'Set command types to query
.Commands(1).CommandType = adCmdText
.Commands(2).CommandType = adCmdText
End With
With DataReport1
'Set report orientation and open preview
.Orientation = rptOrientLandscape
.Show vbModal
End With
It's not until after the "With DataReport1" line that I can see the first recordset
i.e
Debug.Print DataEnvironment1.rscomQuery.RecordCount
but trying to do the same on the second query
Debug.Print DataEnvironment1.rscomQuery2.RecordCount
I get ...
Run Time Error 3704
Operation is not allowed when object is closed
any advice please?
Thanks
Wayne