Display different fields in VB Data Report

90 pts.
Tags:
Database programming
DataEnvironment
VB
VB Data Report
Visual Basic
In VB Data report based on the option selected from Form, the same data report should display different fields. For eg, when I choose "Tution Fees" it should display tution fees only, When I choose "book fees" it should display book fees only. I am using dataenvironment as dat source

Answer Wiki

Thanks. We'll let you know when a new response is added.

If you really mean different <i>fields</i>(not different records), I think you will need to dynamically change the command text of the query.

I don’t know how you are going to design the form to let the user choose what information to see, but for this example, I will assume that you have two buttons, one to show the “tuition fees”, and one for the “book fees”.

I will assume column an table names as well.

<pre>Private Sub btnTuition_Click()
If DataEnvironment1.rsCommand1.State Then
DataEnvironment1.rsCommand1.Close
End If
DataEnvironment1.Commands(1).CommandText = _
“select tuition_fees as fee from fees_table where …” ‘ put the necessary conditions here
DataReport1.Show vbModal
End Sub</pre>

<pre>Private Sub btnBook_Click()

DataEnvironment1.Commands(1).CommandText = _
“select book_fees as fee from fees_table where …” ‘ put the necessary conditions here

DataReport1.Show vbModal
End Sub</pre>

For this example, you should use <i>fee</i> as the DataField property of you rptTextBox (in the DataReport).

If this is not what you needed, please provide more information.

Discuss This Question:  

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following