VB6 Data REport designer

How can I send the content of a textbox to a report?
Imagine that a user needs to print a report of a certain client and  write in some field of a form the client number.
Then the report is printed with the data of that client.
I´m using VB6 with the data report designer and working with a database.

Thanks
asimoesAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

rovermCommented:
Place a label on the DataReport, then before invoking it, change the Caption:

DataReport1.Section("Section").Controls("Label1").Caption = Text1.Text

Good Luck !

RoverM
0
asimoesAuthor Commented:
I´m sorry but I need more than that.
I need to retrieve the record from that client from a table not just show it on the report.
I´m using Data environment with SQL instructions and commands.
And maybe in the SQL sentence I need to put a variable with the textbox content so it can then retrieve the records of that client.

Thanks again.
0
rovermCommented:
Ok, why don't u use parameters then, something like:

SELECT * FROM myTable WHERE clientname LIKE ?

Then, before invoking the DR:

DataEnvironment1.Connection1.comSQL Text1.Text

where comSQL is your sql statement

Then invoke the DR.

RoverM
0
The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

rovermCommented:
Beware: the ? belongs to the sql statement !!!!!!
0
asimoesAuthor Commented:
Hello again
The code you gave me works fine.
But must I have a DataEnvironment "object" working?
How can I create a the equivalent solution but programaticly?
That is, create an environment,
 a command , and a datareport with the sections related to the command.
Becouse I've tried to make everything programaticly (commands,recordsets,assigning the datasource od the datareport to the recordset) but then I cannot control the sections of the datareport.

Thanks

0
rovermCommented:
Yes, you can do that through code, something like:

Dim cn As ADODB.Connection
Dim rs As ADODB.RecordSet

Set cn = New ADODB.Connection
cn.Open "some dsn name or stuff"
rs.Open "sql statement", cn

Then bind the recordset to the DR:

Set DataReport1.DataSource = rs

Then bind all of the TEXT fields to the recordset and so on !
Of course, you cannot drag & drop the fields on your DR because the DR 'doesn't know yet' which database/recordset to use. That's why it's easier to use the dataenv. !

Good luck !
0
asimoesAuthor Commented:
Hello Again
I've already tried what you wrote but the problem is:
When I trie to make a section group in the datareport to separate the information like this:
----header-----------
-----section (client)-----
Client number
------------section (invoices)----
invoice number  date  blablabla
-----------end section (invoices)---
                  sum(somefield)
---close section (client)----
----footer-------
Question:
When I add a section group in the datareport it gives the error telling the datareport does not corresponde with ....

Thanks
0
rovermCommented:
Yep, I know, that's why I don't like the DR !!!!!
However, if you want to see a really good example check out the MSDN libary, disc 1:
e:\samples\vb98\datarept (prjNwind.vbp)

This is an example which uses the DR very nice (but with the use of a dataenv!).

Your problem is that the DR doesn't understand 2 sections referring to the same datasource ! BUT you cannot assign 2 different datasources !!!! Nice huh ?

Check out the example, it uses multiple sections. It can use this by using a 'trick' in the dataenv. It groups and aggregates and adds command.....
See for yourself !

Good Luck !

RoverM
0
asimoesAuthor Commented:
A last and personal question.
What you use if you don´t use the Dataenv.?
The print object directly to the printer and make your own reports?

Thanks you so much for everything.

Alberto Simões
From Portugal
0
rovermCommented:
For every DataReport designer it is easier to use a DataEnvironment because then the DR 'knows' which field are there and you can drag & drop (ok, you can use the DataView window for drag & drop also...).
If you don't want to use a DR then use the printer object. But you have to calculate everything (the coordinates and stuff).

It can be done, but it is way easier to use a datareport.
Why don't u use a DataEnv. ? It's so easy ! Ok, there are a few bugs in there but heck, it's M$ !

Good Luck !

RoverM from The Netherlands
0
rovermCommented:
Ps: Portugal ? Is a nice land for holidays isn't it ? Where should I go, what should I visit ?
grtx, RoverM
0
rovermCommented:
0
asimoesAuthor Commented:
Well Portugal is a Historic country.
So where ever you go there's a lot of monuments to see and in the sommer the beach is the best place to be.
If you like summer and beach then you must go to Algarve in the south of Portugal.


Thanks again
0
rovermCommented:
Asimoes, is your question answered ? Then you should grade it ...

grtx, RoverM
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.