Hi All,

I had puted out my records from database and place them in Datagrid. Than I try to filter out unwanted records based on user inputed date (by using 2 DTPicker, a START DATE and END DATE). And I encounter this problem "Run-time error '3001'". Anyone has any idea what went wrong? Or maybe a better way to filter out those records?

Here is my code...

With Adodc1.Recordset
.Filter = "DOC_DATE Between CStr(DTPicker1.Value) And CStr(DTPicker2.Value)"
If .EOF Then
MsgBox "Item " + txtCustomer.Text + " Not found"
.Requery
txtCustomer.SetFocus
End If
End With

.. .. .. ..

Any help is appreciated.

Thanks.

Recommended Answers

All 2 Replies

Try using only 1 dtpPicker and a text box. Add date selected to the textbox.
In your code add following:
[Set rsAuthorise = New ADODB.Recordset]
[rsAuthorise.Open "SELECT * FROM tablename WHERE] [DateOrdered(your field name related to date) >= DateValue('" &] [txtdate.text & "')" & " ORDER BY DateOrdered", cnConnection,] [adOpenStatic, adLockOptimistic]

Hi AndreRet,

Thank for your reply. It really works by using only one dtpPicker.
Thank you :)

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.