Please help need to see the rdate range from the pickup date of last month to todays date...Whats wrong with this code
Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Shared
Public Class report
Public intv As Integer
Private Sub Report_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
cmbreporttype.Items.Add("Registrationform")
cmbreporttype.Text = "--select--"
datefrom.MaxDate = Today
dateto.MaxDate = Today
connect()
End Sub
Sub Registrationform(ByVal fromdate As String, ByVal todate As String)
Dim rd As New CrystalDecisions.CrystalReports.Engine.ReportDocument
Dim rs As New ADODB.Recordset
Dim sql As String = "select * from postoffice where date between '" & datefrom.Value & "' and '" & dateto.Value & "'"
rs.Open(sql, cn)
rd.Load(Application.StartupPath & "\Registrationform.rpt")
If Not rs.EOF Then
rd.Load(Application.StartupPath & "\Registrationform.rpt")
rd.SetDataSource(rs)
RegistrationformRPT.CrystalReportViewer1.ReportSource = rd
RegistrationformRPT.Show()
Else
MsgBox("Data not found!")
End If
End Sub
Private Sub Button2_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
End Sub
Private Sub cmbreporttype_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmbreporttype.SelectedIndexChanged
intv = DateDiff(DateInterval.Day, datefrom.Value, Today)
If intv < 0 Then
MsgBox("date from cannot exceed date to")
datefrom.Value = Today
dateto.Value = Today
Else : cmbreporttype.Text = "Registrationform"
Registrationform(Format(datefrom.Value, "MM/dd/yyyy"), Format(dateto.Value, "MM/dd/yyyy"))
End If
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
admin.Show()
Me.Hide()
End Sub
Private Sub dateto_LostFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles dateto.LostFocus
Dim intav As Integer = DateDiff(DateInterval.Day, dateto.Value, Today)
If intav < 0 Then
MsgBox("Date cannot Exceed todays Date")
dateto.Value = Today
End If
End Sub
Private Sub datefrom_LostFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles datefrom.LostFocus
Dim intav As Integer = DateDiff(DateInterval.Day, datefrom.Value, Today)
If intav < 0 Then
MsgBox("Date cannot Exceed todays Date")
datefrom.Value = Today
End If
End Sub
End Class