Click here to Skip to main content
15,868,016 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Private Sub Command1_Click()
Call dbConnect


SQL = "SELECT * FROM Expences WHERE ((('Month') Between # " & DTPicker1.Value & "# And # " & DTPicker2.Value & "#))"
RS.Open SQL, Conn, adOpenForwardOnly, adLockReadOnly
With DataReport5.Sections("Section1").Controls 'section1 mean that section you create in datareport
.Item("Text1").DataField = RS("ID").Name
.Item("Text2").DataField = RS("Month").Name
.Item("Text3").DataField = RS("Expenditure").Name
.Item("Text4").DataField = RS("Purpose").Name
.Item("Text5").DataField = RS("Amount").Name

'.Item("Function1").DataField = MyRs("Amount").Name

End With

Set DataReport5.DataSource = RS
DataReport5.Show

End sub


iam using ms-access 2003 database
month datatype as text for that i put 'Month'



but i cannot see the result on data report.


plz help me
Posted
Updated 7-Oct-22 1:32am
v3

Dim stdate As String
Dim edate As String

Adodc1.RecordSource = "SELECT * FROM StockRun WHERE format(SDate,'MM') Between '" & Format(DTPicker1.Value, "MM") & "' And '" & Format(DTPicker2.Value, "MM") & "'"
Adodc1.Refresh
Text1.Text = Adodc1.RecordSource

SDate Record needs to be formatted as well to get a match....
this worked fine
 
Share this answer
 
v2
Comments
Dave Kreskowiak 7-Oct-22 8:10am    
You might want to stick to answering questions that were asked in the current decade.
Member 13532114 7-Oct-22 9:56am    
Some of us still have to maintain legacy systems, So this resource is valuable when trying to sort out older systems and maintain. It is of great use to me and prob others. So any input now or from the past is of great value to me. Why are you here !!. so be kind enough and keep that sort of comment to yourself..
SQL = "SELECT * " & _
"FROM Expences " & _
"WHERE ( '13/Oct/20013' Between '" & Format(DTPicker1.Value,"dd/MMM/yyyy") & "' And '" & Format(DTPicker2.Value,"dd/MMM/yyyy") & "')"


Note: '13/Oct/20013', is the variable date which will be compared with front end.
Fromatting date in dd/MMM/yyyy (i.e. 13/Oct/2013) is a good practice but if you are using the fornt end in a multilingual platform please compare it with sql server mm-dd-yyyy format.
 
Share this answer
 
v2
Try this.

If the month is in MM format then,
SELECT * FROM Expences WHERE ('Month') Between '" & Format(DTPicker1.Value, "MM") & "' And '" & Format(DTPicker2.Value, "MM") & "' 


Hope this will solve ur problem.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900