VB6 Data Environment & Data Report 
Author Message
 VB6 Data Environment & Data Report

i have 2 questions to ask.  one about the Data Environment, and one about
the Data Report.

1. in the data environment i have built a connection, and a command object.
the command object is using a SQL Statement to create a recordset.  my
question is how can i pass a variable into this SQL Select like i would in a
recordsource.  such as:

"SELECT * FROM Table WHERE Field = '" & Variable & "'"

i want to do this because i often want to search something like a customer
table for a specific Last Name the user enters.  i hope this is possible to
do.

2.  in a data report how can i print only the selected record in a
recordset.  such as if i have an employee recordset and i want to print info
for just one of say 10 employees, how would that be acomplished?

if anyone can help me that would be great.  thanks.

Guy



Sat, 23 Mar 2002 03:00:00 GMT  
 VB6 Data Environment & Data Report
I think all of this will have to be done with code.

Leave your setup of the data environment and data report as you have it, but
for 1, change the underlying SQL of the command object in code.  For 2, use
a  second instance of the recordset in question to display the recordset on
a form so that the user can select the record wanted, then use code to
change the underlying SQL of the command object so that the only record in
the command object is the selected record.


Quote:
> i have 2 questions to ask.  one about the Data Environment, and one about
> the Data Report.

> 1. in the data environment i have built a connection, and a command
object.
> the command object is using a SQL Statement to create a recordset.  my
> question is how can i pass a variable into this SQL Select like i would in
a
> recordsource.  such as:

> "SELECT * FROM Table WHERE Field = '" & Variable & "'"

> i want to do this because i often want to search something like a customer
> table for a specific Last Name the user enters.  i hope this is possible
to
> do.

> 2.  in a data report how can i print only the selected record in a
> recordset.  such as if i have an employee recordset and i want to print
info
> for just one of say 10 employees, how would that be acomplished?

> if anyone can help me that would be great.  thanks.

> Guy



Sun, 24 Mar 2002 03:00:00 GMT  
 VB6 Data Environment & Data Report
i don't really understand what you mean?  any extra help would be great.
thanks.
Quote:

>I think all of this will have to be done with code.

>Leave your setup of the data environment and data report as you have it,
but
>for 1, change the underlying SQL of the command object in code.  For 2, use
>a  second instance of the recordset in question to display the recordset on
>a form so that the user can select the record wanted, then use code to
>change the underlying SQL of the command object so that the only record in
>the command object is the selected record.



>> i have 2 questions to ask.  one about the Data Environment, and one about
>> the Data Report.

>> 1. in the data environment i have built a connection, and a command
>object.
>> the command object is using a SQL Statement to create a recordset.  my
>> question is how can i pass a variable into this SQL Select like i would
in
>a
>> recordsource.  such as:

>> "SELECT * FROM Table WHERE Field = '" & Variable & "'"

>> i want to do this because i often want to search something like a
customer
>> table for a specific Last Name the user enters.  i hope this is possible
>to
>> do.

>> 2.  in a data report how can i print only the selected record in a
>> recordset.  such as if i have an employee recordset and i want to print
>info
>> for just one of say 10 employees, how would that be acomplished?

>> if anyone can help me that would be great.  thanks.

>> Guy



Sat, 30 Mar 2002 03:00:00 GMT  
 VB6 Data Environment & Data Report
SQL in DE:
SELECT * FROM Table WHERE (Field = ?)
The "?" is the variable (use the ?, do not replace) If you go to the parameter
tab
you will see the ? listed as the parameter.

In code to open report:
DataEnv1.Command1 txtField.text    'where txtField.txt is holding the search
variable
ie. employee number.
DataReport1.Show

It works for me.
-Fitz

Quote:



> >> i have 2 questions to ask.  one about the Data Environment, and one about
> >> the Data Report.

> >> 1. in the data environment i have built a connection, and a command
> >object.
> >> the command object is using a SQL Statement to create a recordset.  my
> >> question is how can i pass a variable into this SQL Select like i would
> in
> >a
> >> recordsource.  such as:

> >> "SELECT * FROM Table WHERE Field = '" & Variable & "'"

> >> i want to do this because i often want to search something like a
> customer
> >> table for a specific Last Name the user enters.  i hope this is possible
> >to
> >> do.

> >> 2.  in a data report how can i print only the selected record in a
> >> recordset.  such as if i have an employee recordset and i want to print
> >info
> >> for just one of say 10 employees, how would that be acomplished?

> >> if anyone can help me that would be great.  thanks.

> >> Guy



Sat, 30 Mar 2002 03:00:00 GMT  
 VB6 Data Environment & Data Report
i tried this exact some thing already and when i went to pass the parameter
it returned nothing.  do i need to refresh or something?
Quote:

>SQL in DE:
>SELECT * FROM Table WHERE (Field = ?)
>The "?" is the variable (use the ?, do not replace) If you go to the
parameter
>tab
>you will see the ? listed as the parameter.

>In code to open report:
>DataEnv1.Command1 txtField.text    'where txtField.txt is holding the
search
>variable
>ie. employee number.
>DataReport1.Show

>It works for me.
>-Fitz



>> >> i have 2 questions to ask.  one about the Data Environment, and one
about
>> >> the Data Report.

>> >> 1. in the data environment i have built a connection, and a command
>> >object.
>> >> the command object is using a SQL Statement to create a recordset.  my
>> >> question is how can i pass a variable into this SQL Select like i
would
>> in
>> >a
>> >> recordsource.  such as:

>> >> "SELECT * FROM Table WHERE Field = '" & Variable & "'"

>> >> i want to do this because i often want to search something like a
>> customer
>> >> table for a specific Last Name the user enters.  i hope this is
possible
>> >to
>> >> do.

>> >> 2.  in a data report how can i print only the selected record in a
>> >> recordset.  such as if i have an employee recordset and i want to
print
>> >info
>> >> for just one of say 10 employees, how would that be acomplished?

>> >> if anyone can help me that would be great.  thanks.

>> >> Guy



Mon, 01 Apr 2002 03:00:00 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. MTS & VB6 Data Report and Data Environment

2. Data Environment & DHTML document in VB6

3. VB6: Data Environment & SQL Server 6.5

4. Data Project, data environment & Oracle

5. Data Environment / Data Report Problem

6. Showing parameters pass to data environment in data report header

7. Help! Data Report without Data Environment

8. data report / data environment designers

9. Data Environment / Data Report / Changing database file at run time

10. Problem with Data Environment and Data Report

11. help - data environment and data reports

12. Data Environment / Data Report Problem

 

 
Powered by phpBB® Forum Software