I want to filter age range based on two (2) textboxes value. I have two (2) textboxes in a form, the first textbox is for beginning of range and second is for ending of range (example: 45(first textbox) to 60(second textbox)).A report is containing student's fullname, date of birth, and age column. The age column is not from the database but from the expression: round(DateDiff("m",fields!DOB.Value,Now() )/12)
I tried the code below but it did not work:
Code:Dim connstring As String connstring = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=studentrecords.accdb" Dim conn As OleDbConnection = New OleDbConnection(connstring) Dim displaystr As String = "SELECT studentfullname, dateofbirth, Round(DateDiff('m',studenprofile_records.Date_of_Birth,Date())/12,2) AS Age FROM studentprofile_records WHERE Age BETWEEN'" & CInt(txtagefrom.Text) & "' AND Age <='" & CInt(txtageto.Text) & "'" Dim cmddisplay As New OleDbCommand(displaystr, conn) conn.Open() cmddisplay.ExecuteNonQuery() conn.Close() Me.ReportViewer1.SetDisplayMode(Microsoft.Reporting.WinForms.ZoomMode.PageWidth) Me.ReportViewer1.RefreshReport()




Reply With Quote
