I have 2 collumn from my database. DateHired ( datarow.item(5)) and EndofContract (datarow.item(6))
on my form i have 2 datetimepicker to record the employees previous jobs, i need to avoid overlapping on the employees recent recorded jobs.
e.g if date hired is 01/02/2012 and end of contract is 05/30/2012 all dates beetween it must not be available if the user try to input date between it, it must notify the user that it is invalid.
my code dont have errors yet it doesnt function well.
e.g if ihave saved date hired is 01/02/2012 and end of contract is 05/30/2012, if again i try to input 01/05/2012 to 05/30/2012 it can trace that its not available yet if i input 01/01/2012 to 05/30/2012 it just didnt trace it,, i dont know how to implement this right hope someone to help.. thanks
Private Function datetest() Dim con As New OleDbConnection con.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source =..\systemsdbs.accdb" Dim dt As New DataTable Dim ds As New DataSet ds.Tables.Add(dt) con.Open() Dim da As New OleDbDataAdapter("select * from tblempjobhist where ID like '%" & lbljobhistid.Text & "%'", con) da.Fill(dt) For Each datarow In dt.Rows If ((txtjobhired.Value.Date >= datarow.item(5)) And (txtjobend.Value.Date <= datarow.item(6))) Then con.Close() Return True End If Next con.Close() Return False End Function
if record exist it must return true, otherwise it will return false.