Hi everyone

I had a problem with the datareports
I am using MS access as database and VB 6
In the section 1 i had place text box and i want in text box the values
value 1 - value 2.

The code is given below
Please help me

Thanks

Private Sub DataReport_Initialize()
Set rs_cash_rd = New Recordset
If rs_cash_rd.State = 1 Then rs_cash_rd.Close
rs_cash_rd.Open "Select * from cash_paid where company = '" & frm_customer_reports.cmb_vendorList & "' order by invdate, invno", cn, 2, 3
Set DataReport1.DataSource = rs_cash_rd
Set DataReport1.DataSource = rs_cash_rd.DataSource

Set rs_cash_op = New Recordset
If rs_cash_op.State = 1 Then rs_cash_op.Close


With DataReport1
With .Sections("Section2").Controls
.Item("lbl_vendor").Caption = frm_customer_reports.cmb_vendorList
End With

With .Sections("Section1").Controls
Do While Not rs_cash_rd.EOF
.Item("txt_date").DataField = rs_cash_rd![invdate].Name
.Item("txt_invno").DataField = rs_cash_rd![invno].Name
If rs_cash_op.State = 1 Then rs_cash_op.Close
rs_cash_op.Open "Select invamt, amt_paid from cash_paid where company = '" & frm_customer_reports.cmb_vendorList & "' and invno = '" & rs_cash_rd![invno] & "' order by invdate", cn, 2, 3
.Item("txt_description").DataField = rs_cash_rd![mode_paid].Name
'.Item("txt_amtdue").DataField = rs_cash_rd![invamt].Name
.Item("txt_amtdue").DataField = rs_cash_op![invamt] - rs_cash_op![amt_paid]
.Item("txt_amtpaid").DataField = rs_cash_rd![amt_paid].Name
rs_cash_rd.MoveNext
rs_cash_op.MoveNext
Loop
End With
End With

Wow!!!, or should I say ouch. lol

First of all you have set your datagrid's datasource to the same recordset TWICE.

Set DataReport1.DataSource = rs_cash_rd
Set DataReport1.DataSource = rs_cash_rd.DataSource

The first one is correct - Set DataReport1.DataSource = rs_cash_rd

Secondly, what text are you getting from your combobox on ANOTHER form. It will select only the first indexed item (the first entry in the combobox) - cmb_vendorList. Is this the correct data you required?

Otherwise, to help you get the values into a textbox, go the following post from this afternoon where I have already posted the code for someone else -

http://http://www.daniweb.com/forums/thread238881.html

Good luck...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.