VB6 Data Environment & Data Report

VB6 Data Environment & Data Report

Post by Guy » Wed, 06 Oct 1999 04:00:00



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

 
 
 

VB6 Data Environment & Data Report

Post by William F. LaMarti » Thu, 07 Oct 1999 04:00:00


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


 
 
 

VB6 Data Environment & Data Report

Post by Guy » Wed, 13 Oct 1999 04:00:00


i don't really understand what you mean?  any extra help would be great.
thanks.

>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

 
 
 

VB6 Data Environment & Data Report

Post by M Fitzgeral » Wed, 13 Oct 1999 04:00:00


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

 
 
 

VB6 Data Environment & Data Report

Post by Guy » Fri, 15 Oct 1999 04:00:00


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?

>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

 
 
 

1. Data Environment & DHTML document in VB6

Hi there,
I'm trying to make a DHTML page that will connect to a SQL 7 DB. I've
made forms that can do it, but I can't get it to work right in DHTML.
I asked some of the VB programmers at my office and they told me to
just do it in ASP and skip VB.
Anyway I was wondering if anyone can tell me what I'm doing wrong,,
also i was wondering (you can probly tell I'm pretty inexperienced
here) if this is even an appropriate way to create a web-accessble
front end? or are the guys right,, i should just do it in asp?

thanks in advance

-NBinSD

2. Data clipping in report

3. VB6: Data Environment & SQL Server 6.5

4. convert DBASE-tables

5. Help! Data Report without Data Environment

6. Key Violation on Paradox: How to get the TABLENAME?

7. Data Report without Data Environment

8. Shutting Oracle Down for Backup

9. Problem with Data Environment and Data Report

10. data report / data environment designers

11. Data Report w/out Data Environment?

12. MNS VB 6.0 Data Environment and Data Report Run time problem

13. help - data environment and data reports