Hye All
Please help me to create Data Reports Accourding to given Dates. I Created a VB6 Form put 2 Time/Date Picker Controls and one Command Button.what will be code for Button to display Report Between given dates.

Before going to your question, let me ask first. What DBMS you are using and what reporting tool you are using?

Private Sub Command1_Click()

DataReport6.Sections("section4").Controls.Item("Label3").Caption = MaskDate1.Text
DataReport6.Sections("section4").Controls.Item("Label9").Caption = MaskDate2.Text

Dim rs_B As New ADODB.Recordset
Dim Crs As Integer
On Error Resume Next
rs_B.Open "Select * FROM Inv_Tab WHERE InvDate BETWEEN #" & CDate(MaskDate1.Text) & " # AND # " & CDate(MaskDate2.Text) & "#", conn, adOpenDynamic, adLockOptimistic

Crs = 0

With DataReport6
Set .DataSource = Nothing
.DataMember = ""
Set .DataSource = rs_B.DataSource

'''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''''''''''''
'This section to display information in the section1 of the report. A loop is ised to display multiple records.
'''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''''''''''''''''

With .Sections("Section1").Controls
For i = 1 To .Count

If TypeOf .Item(i) Is RptTextBox Then
.Item(i).DataMember = ""
.Item(i).DataField = rs_B.Fields(Crs).Name
Crs = Crs + 1

End If

Next i
End With
End With
'Set DataReport6.DataSource = rs_B

Set rs_B = Nothing

End Sub

This question has already been answered. Start a new discussion instead.