Question search date of birth between two date time picker

Bangus

New member
Joined
Apr 14, 2010
Messages
1
Location
Bangus Capital of the World
Programming Experience
1-3
hello there, I'm actually creating an HR System for my thesis. I'm using VS.Net 2003 with MS-Access Database. I have these table as tblemployee, where all the employees profile saved. I'm done with searching by ID #, Last-First-Middle Name, my main problem is that I want to search all employees birthdate between two date time picker and display on a listbox, after that there is a print button and it will display the output from listbox to crystal report.

I have this two date time picker as dbayfrom and dbdayto, listbox, two buttons as cmdfind and cmdprint, here is my code:

Private Sub cmdfind_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdfind.Click
Dim db As New ADODB.Connection
Dim rs As New ADODB.Recordset
db.Open("Provider=microsoft.jet.oledb.4.0;data source=" & Application.StartupPath & "\employee.mdb")
Try
rs.Open("SELECT * FROM tblemployee WHERE DOB BETWEEN '" & dbdayfrom.Text & "' AND '" & dbdayto.Text & "'", db)
Try
rs.MoveFirst()
ListBox1.Items.Clear()
Do
ListBox1.Items.Add((rs.Fields("id").Value) & " - " & (rs.Fields("lastname").Value) & ", " & (rs.Fields("firstname").Value) & " " & (rs.Fields("middlename").Value))
rs.MoveNext()
Loop While Not rs.EOF
Catch ex As Exception
ListBox1.Items.Clear()
ListBox1.Items.Add("No Records Found")
MessageBox.Show(ex.Message)
End Try
rs.Close()
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub

when i trigger the cmdfind button, the result from the listbox is "No Records Found." There are records that have a DOB between October 13, 1983 and October 29, 1983. If i select the date between October 1-31, 1983 it will display the two employees. What I want to see even the year is 2010, I can still search for the entire month even the present year.

Could anyone help me? Thanks in advance! :confused:
 
Top Bottom