0

hi can someone tell me how can I search the database using dtpicker. I am usinf vb6 and ms 2003 and I need to display the date of birth of a on 3 textboxes,namely the firstname, lastname and middlename and also in a listview. please help me. this is my primary code for that but it is not working:

Private Sub search_image ()
dim rs as recordset
dim list as listitems
set rs = new recorset
rs.open "select * from tblrecord where Birthday = '" & DTPicker1 & "'", cn, adOpenDynamic, adLockOptimistic


If RS.EOF Then
MsgBox "Record Not Found!", vbExclamatio
Else
lastn.text = RS.Fields("Lastname")
'etc....
lsvrec.ListItems.Clear
Set list = lsvbap.ListItems.Add(, , RS!Lastname)
    list.ListItems.SubItems(1) = RS!Firstname
    list.ListItems.SubItems(2) = RS!Middlename
End If
End Sub

please help. :)

3
Contributors
3
Replies
5
Views
6 Years
Discussion Span
Last Post by AndreRet
0

Change your sql statement to the following -

Dim strDate As Date
strDate = dtPicker1.Value

rs.open "SELECT * FROM tblrecord WHERE Birthday = DateValue('" & strDate & "')", cn, adOpenDynamic, adLockOptimistic
0

rs.open "select * from tblrecord where Birthday = '" & DTPicker1.value & "'", cn, adOpenDynamic, adLockOptimistic

0

@UnderSurvival, please mark this thread as solved if you have managed to get a solution, found at the bottom of this page, thanks.:)

It has been open for some time now.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.