90 pts.
 Display different fields in VB Data Report
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

Software/Hardware used:
ASKED: November 25, 2008  4:06 AM
UPDATED: November 26, 2008  8:01 PM

Answer Wiki:
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.
Last Wiki Answer Submitted:  November 26, 2008  8:01 pm  by  carlosdl   63,535 pts.
All Answer Wiki Contributors:  carlosdl   63,535 pts.
To see all answers submitted to the Answer Wiki: View Answer History.


Discuss This Question:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _