Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to do a date Search

Status
Not open for further replies.

1x2z3

Programmer
Sep 18, 2003
39
0
0
ZA

1. I`am searching for a Birthdate.
2. When i type the date in it shows that the date was`nt found, although the date exists.
3. The format i`am using is "yyyy-mm-dd" (2006-07-08) in vb as well as in the Access database.
4. I`am using the following code in the search cmd :

rs.Close
rs.Source = "Select * from Addresses where Birthdate like '" & txtSearch.Text & "%'order by Name"
rs.Open

If rs.RecordCount = 0 Then
rs.Close
rs.Source = "select * from Adresses order by Birthdate"
rs.Open

If MsgBox("No Records was found. Find Again...", vbYesNo + vbExclamation, "No Records...") =
vbYes Then
DisableSave
chkSearch_Click

Else
cmdRefresh_Click
End If


Else: MsgBox "Records Found : " & rs.RecordCount, vbInformation, "Found..."
chkSearch.Value = Unchecked
Populatecontrols
End If

If cmdAdd.Visible = False Then
DisableCommands
End If

 
where Birthdate like '" & txtSearch.Text & "%'order by Name"

should be

where Birthdate = #" & txtSearch.Text & "# order by [Name]"

Unless you are in the US, you may well have problems with date formats. This will fix it.

where Birthdate = #" & Format(txtSearch.Text, "dd mmm yyyy") & "# order by [Name]"

The date will not be confused with another
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top