VB6 Dataenvironment & Datareport

VB6 Dataenvironment & Datareport

Post by Allan Slad » Fri, 02 Oct 1998 04:00:00



Hi All, I need some help with connecting my Report to the Environment. If I
Execute a SQL-question (in the Dataenvironment, from my VB-Code) and want
the report to show the result of the SQL-Question.... The Data report only
shows the enire contents of my DB.

How do I set Datareport1.Datameber to the Dataenvironment1.rsResultset ??

I have tried all (!!) possible combinations.... nothing works :-(

in my VB Code i can access the rsResultset and print the correct result of
my SQL.. But I cant get the Datareport to use the rsResultset.

I know that there is something I don't understand, but I don't know what I
don't understand.

Can someone Please Help me ?

 
 
 

VB6 Dataenvironment & Datareport

Post by Henry Ari » Sat, 03 Oct 1998 04:00:00


If you used the dataenvironment to create a SQLQuery and then bound
the datareport to that the datareport will be constrained by the SQL
Query, now if you manipulate the database and are having problems with
the data showing up in the report then try this code in the
datareport's Initialize Procedure

On Error GoTo Err
'if not open then open the recordset, needed only if the recordset has
never been initialized

DataConnODBC.rsSQLAmbDisc.Open
DataConnODBC.rsSQLAmbDisc.Requery
'refresh data for report

Exit Sub
Err:
'if the recordset has been opened then just refresh the data for the
report
DataConnODBC.rsSQLAmbDisc.Requery

This is based on an SQLQuery Called SQLAmbDisc, see how the
dataconnection designed turns it into a recordset for you. You can
also execute commands without much code, like:

DataConnODBC.rsSQLAmbDisc.MoveFirst
DataConnODBC.rsSQLAmbDisc.MoveNext

and so on, also notice that there is no Refresh, it is now Requery,
although for some reason it takes Refresh, however, the recordset is
not refreshed and no error is generated. Go figure.. Henry

On Thu, 1 Oct 1998 17:47:55 +0200, "Allan Sladd"


>Hi All, I need some help with connecting my Report to the Environment. If I
>Execute a SQL-question (in the Dataenvironment, from my VB-Code) and want
>the report to show the result of the SQL-Question.... The Data report only
>shows the enire contents of my DB.

>How do I set Datareport1.Datameber to the Dataenvironment1.rsResultset ??

>I have tried all (!!) possible combinations.... nothing works :-(

>in my VB Code i can access the rsResultset and print the correct result of
>my SQL.. But I cant get the Datareport to use the rsResultset.

>I know that there is something I don't understand, but I don't know what I
>don't understand.

>Can someone Please Help me ?