Hello Guys, I need Your Help,, im just Worried for declaring the Month of January, Because whenI search Month of January , The Month of October, November, And december, Would Appear.
I want to search is The Month of January Only.
This is My Code.
January = 1
February = 2
March = 3
April = 4
May = 5
June = 6
July = 7
August = 8
September = 9
October = 10
November = 11
December = 12
Dim listx As ListItem
Dim rs As New ADODB.Recordset
'January ----------------------------------------------------------------------------------------------
If Combo1.Text = "January" Then
rs.Open "Select * from Dailyrecord where purchase_date Like '" & January & "%'", acd, adOpenForwardOnly
If rs.RecordCount = 0 Then
MsgBox "The Date you Select Does Not Exist!", vbExclamation, "Details"
Else
ListView1.ListItems.clear
While rs.EOF <> True
Set listx = ListView1.ListItems.Add(, , rs.Fields("Receipt"))
listx.SubItems(1) = rs.Fields("BarCode")
listx.SubItems(2) = rs.Fields("ProductName")
listx.SubItems(3) = rs.Fields("Quantity")
listx.SubItems(4) = rs.Fields("Price")
listx.SubItems(5) = rs.Fields("TotalPrice")
listx.SubItems(6) = rs.Fields("purchase_date")
rs.MoveNext
Wend
monthlyreport.Enabled = True
End If
End If
'February ------------------------------------------------------------------------------------------------
If Combo1.Text = "February" Then
rs.Open "Select * from Dailyrecord where purchase_date Like '" & February & "%'", acd, adOpenForwardOnly
If rs.RecordCount = 0 Then
MsgBox "The Date you Select Does Not Exist!", vbExclamation, "Details"
Else
ListView1.ListItems.clear
While rs.EOF <> True
Set listx = ListView1.ListItems.Add(, , rs.Fields("Receipt"))
listx.SubItems(1) = rs.Fields("BarCode")
listx.SubItems(2) = rs.Fields("ProductName")
listx.SubItems(3) = rs.Fields("Quantity")
listx.SubItems(4) = rs.Fields("Price")
listx.SubItems(5) = rs.Fields("TotalPrice")
listx.SubItems(6) = rs.Fields("purchase_date")
rs.MoveNext
Wend
dailyreport.Enabled = True
monthlyreport.Enabled = True
End If
End If
'march----------------------------------------------------------------------------------------------------
If Combo1.Text = "March" Then
rs.Open "Select * from Dailyrecord where purchase_date Like '" & March & "%'", acd, adOpenForwardOnly
If rs.RecordCount = 0 Then
MsgBox "The Date you Select Does Not Exist!", vbExclamation, "Details"
Else
ListView1.ListItems.clear
While rs.EOF <> True
Set listx = ListView1.ListItems.Add(, , rs.Fields("Receipt"))
listx.SubItems(1) = rs.Fields("BarCode")
listx.SubItems(2) = rs.Fields("ProductName")
listx.SubItems(3) = rs.Fields("Quantity")
listx.SubItems(4) = rs.Fields("Price")
listx.SubItems(5) = rs.Fields("TotalPrice")
listx.SubItems(6) = rs.Fields("purchase_date")
rs.MoveNext
Wend
dailyreport.Enabled = True
monthlyreport.Enabled = True
End If
End If
'April ----------------------------------------------------------------------------------------------
If Combo1.Text = "April" Then
rs.Open "Select * from Dailyrecord where purchase_date Like '" & April & "%'", acd, adOpenForwardOnly
If rs.RecordCount = 0 Then
MsgBox "The Date you Select Does Not Exist!", vbExclamation, "Details"
Else
ListView1.ListItems.clear
While rs.EOF <> True
Set listx = ListView1.ListItems.Add(, , rs.Fields("Receipt"))
listx.SubItems(1) = rs.Fields("BarCode")
listx.SubItems(2) = rs.Fields("ProductName")
listx.SubItems(3) = rs.Fields("Quantity")
listx.SubItems(4) = rs.Fields("Price")
listx.SubItems(5) = rs.Fields("TotalPrice")
listx.SubItems(6) = rs.Fields("purchase_date")
rs.MoveNext
Wend
dailyreport.Enabled = True
monthlyreport.Enabled = True
End If
End If
'May ------------------------------------------------------------------------------------------------
If Combo1.Text = "May" Then
rs.Open "Select * from Dailyrecord where purchase_date Like '" & May & "%'", acd, adOpenForwardOnly
If rs.RecordCount = 0 Then
MsgBox "The Date you Select Does Not Exist!", vbExclamation, "Details"
Else
ListView1.ListItems.clear
While rs.EOF <> True
Set listx = ListView1.ListItems.Add(, , rs.Fields("Receipt"))
listx.SubItems(1) = rs.Fields("BarCode")
listx.SubItems(2) = rs.Fields("ProductName")
listx.SubItems(3) = rs.Fields("Quantity")
listx.SubItems(4) = rs.Fields("Price")
listx.SubItems(5) = rs.Fields("TotalPrice")
listx.SubItems(6) = rs.Fields("purchase_date")
rs.MoveNext
Wend
dailyreport.Enabled = True
monthlyreport.Enabled = True
End If
End If
'June ----------------------------------------------------------------------------------------------------
If Combo1.Text = "June" Then
rs.Open "Select * from Dailyrecord where purchase_date Like '" & June & "%'", acd, adOpenForwardOnly
If rs.RecordCount = 0 Then
MsgBox "The Date you Select Does Not Exist!", vbExclamation, "Details"
Else
ListView1.ListItems.clear
While rs.EOF <> True
Set listx = ListView1.ListItems.Add(, , rs.Fields("Receipt"))
listx.SubItems(1) = rs.Fields("BarCode")
listx.SubItems(2) = rs.Fields("ProductName")
listx.SubItems(3) = rs.Fields("Quantity")
listx.SubItems(4) = rs.Fields("Price")
listx.SubItems(5) = rs.Fields("TotalPrice")
listx.SubItems(6) = rs.Fields("purchase_date")
rs.MoveNext
Wend
dailyreport.Enabled = True
monthlyreport.Enabled = True
End If
End If
'July ----------------------------------------------------------------------------------------------
If Combo1.Text = "July" Then
rs.Open "Select * from Dailyrecord where purchase_date Like '" & July & "%'", acd, adOpenForwardOnly
If rs.RecordCount = 0 Then
MsgBox "The Date you Select Does Not Exist!", vbExclamation, "Details"
Else
ListView1.ListItems.clear
While rs.EOF <> True
Set listx = ListView1.ListItems.Add(, , rs.Fields("Receipt"))
listx.SubItems(1) = rs.Fields("BarCode")
listx.SubItems(2) = rs.Fields("ProductName")
listx.SubItems(3) = rs.Fields("Quantity")
listx.SubItems(4) = rs.Fields("Price")
listx.SubItems(5) = rs.Fields("TotalPrice")
listx.SubItems(6) = rs.Fields("purchase_date")
rs.MoveNext
Wend
dailyreport.Enabled = True
monthlyreport.Enabled = True
End If
End If
'August ------------------------------------------------------------------------------------------------
If Combo1.Text = "August" Then
rs.Open "Select * from Dailyrecord where purchase_date Like '" & August & "%'", acd, adOpenForwardOnly
If rs.RecordCount = 0 Then
MsgBox "The Date you Select Does Not Exist!", vbExclamation, "Details"
Else
ListView1.ListItems.clear
While rs.EOF <> True
Set listx = ListView1.ListItems.Add(, , rs.Fields("Receipt"))
listx.SubItems(1) = rs.Fields("BarCode")
listx.SubItems(2) = rs.Fields("ProductName")
listx.SubItems(3) = rs.Fields("Quantity")
listx.SubItems(4) = rs.Fields("Price")
listx.SubItems(5) = rs.Fields("TotalPrice")
listx.SubItems(6) = rs.Fields("purchase_date")
rs.MoveNext
Wend
dailyreport.Enabled = True
monthlyreport.Enabled = True
End If
End If
'September----------------------------------------------------------------------------------------------------
If Combo1.Text = "September" Then
rs.Open "Select * from Dailyrecord where purchase_date Like '" & September & "%'", acd, adOpenForwardOnly
If rs.RecordCount = 0 Then
MsgBox "The Date you Select Does Not Exist!", vbExclamation, "Details"
Else
ListView1.ListItems.clear
While rs.EOF <> True
Set listx = ListView1.ListItems.Add(, , rs.Fields("Receipt"))
listx.SubItems(1) = rs.Fields("BarCode")
listx.SubItems(2) = rs.Fields("ProductName")
listx.SubItems(3) = rs.Fields("Quantity")
listx.SubItems(4) = rs.Fields("Price")
listx.SubItems(5) = rs.Fields("TotalPrice")
listx.SubItems(6) = rs.Fields("purchase_date")
rs.MoveNext
Wend
dailyreport.Enabled = True
monthlyreport.Enabled = True
End If
End If
'October ----------------------------------------------------------------------------------------------
If Combo1.Text = "October" Then
rs.Open "Select * from Dailyrecord where purchase_date Like '" & October & "%'", acd, adOpenForwardOnly
If rs.RecordCount = 0 Then
MsgBox "The Date you Select Does Not Exist!", vbExclamation, "Details"
Else
ListView1.ListItems.clear
While rs.EOF <> True
Set listx = ListView1.ListItems.Add(, , rs.Fields("Receipt"))
listx.SubItems(1) = rs.Fields("BarCode")
listx.SubItems(2) = rs.Fields("ProductName")
listx.SubItems(3) = rs.Fields("Quantity")
listx.SubItems(4) = rs.Fields("Price")
listx.SubItems(5) = rs.Fields("TotalPrice")
listx.SubItems(6) = rs.Fields("purchase_date")
rs.MoveNext
Wend
dailyreport.Enabled = True
monthlyreport.Enabled = True
End If
End If
'November----------------------------------------------------------------------------------------------------
If Combo1.Text = "November" Then
rs.Open "Select * from Dailyrecord where purchase_date Like '" & November & "%'", acd, adOpenForwardOnly
If rs.RecordCount = 0 Then
MsgBox "The Date you Select Does Not Exist!", vbExclamation, "Details"
Else
ListView1.ListItems.clear
While rs.EOF <> True
Set listx = ListView1.ListItems.Add(, , rs.Fields("Receipt"))
listx.SubItems(1) = rs.Fields("BarCode")
listx.SubItems(2) = rs.Fields("ProductName")
listx.SubItems(3) = rs.Fields("Quantity")
listx.SubItems(4) = rs.Fields("Price")
listx.SubItems(5) = rs.Fields("TotalPrice")
listx.SubItems(6) = rs.Fields("purchase_date")
rs.MoveNext
Wend
dailyreport.Enabled = True
monthlyreport.Enabled = True
End If
End If
'December ------------------------------------------------------------------------------------------------
If Combo1.Text = "December" Then
rs.Open "Select * from Dailyrecord where purchase_date Like '" & December & "%'", acd, adOpenForwardOnly
If rs.RecordCount = 0 Then
MsgBox "The Date you Select Does Not Exist!", vbExclamation, "Details"
Else
ListView1.ListItems.clear
While rs.EOF <> True
Set listx = ListView1.ListItems.Add(, , rs.Fields("Receipt"))
listx.SubItems(1) = rs.Fields("BarCode")
listx.SubItems(2) = rs.Fields("ProductName")
listx.SubItems(3) = rs.Fields("Quantity")
listx.SubItems(4) = rs.Fields("Price")
listx.SubItems(5) = rs.Fields("TotalPrice")
listx.SubItems(6) = rs.Fields("purchase_date")
rs.MoveNext
Wend
dailyreport.Enabled = True
monthlyreport.Enabled = True
End If
End If
monthlyreport.Enabled = True
Help me Guys, Thanks in Adavance