hi all, I have create a database application in vb 6.0 i need to retrive some reports using data report (not Crystal) such as date wise report or customer wise report. The steps i fallowed are: 1. retrived text boxes in data report 2. for date wise report , created a form providing calendar to choose date. 3. on command button the code is :
With DataReport1 Set .DataSource = Nothing .DataMember = "" Set .DataSource = RS.DataSource With .Sections("Section1").Controls For i = 1 To .Count If TypeOf .Item(i) Is RptTextBox Then .Item(i).DataMember = "" .Item(i).DataField = RS.Fields(i).Name End If Next i End With 4. the code executed apporximately as per date report. Now the problem is about Customer report. I need all transactions of the same customer with Customer name and account no on header and other transaction contents on detail section. provicde : the data base fields are custname,custno,date,credit,debit,balance .....
plz help....
Check out the following sample code.
Dim Mycon As New ADODB.Connection
Dim M1 As New ADODB.Recordset
Dim M2 As New ADODB.Recordset
Dim S1 As String
S1 = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & _
App.Path & "check.mdb"
Mycon.Open S1
M2.Open "select customer_id,orderno,delivery_date,order_date,dress_name " & _
"from dress_details where delivery_date>=#" & DTPicker1.Value & "# and delivery_date <=# " & DTPicker2.Value & "# order by delivery_date", _
Mycon, adOpenDynamic, adLockOptimistic
'I have used DTPicker control for dates. So change it to your table and details accordingly.
Set DataReport1.DataSource = M2
With DataReport1
.Sections("Section1").Controls
For i = 1 To .Count
If TypeOf .Item(i) Is RptTextBox Then
.Item(i).DataMember = ""
.Item(i).DataField = M2.Fields(i).Name
End If
Next i
End With
DataReport1.WindowState = vbMaximized
DataReport1.Show vbModal
M2.Close
Mycon.Close