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!

DataReports advice 1

Status
Not open for further replies.

WBH1138

Programmer
May 31, 2002
85
GB
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
 
There should be an similar named method in the DE object to call first in order to open the rs, such as

DataEnvironment1.comQuery2
or just
DataEnvironment1.Query2

Type DataEnvironment1. and the intellisense should give you a list of methods to call. Search this list.

Once you call this, then you should be able to access the RS.
 
Yes, I used the DataEnvironment1.<rsname>.Open command and that gave me the recordset for pre-reporting processing.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top