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. :)

Recommended Answers

All 3 Replies

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

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

@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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.