|
-
Mar 25th, 2008, 06:09 PM
#1
Thread Starter
New Member
Access Database Date Filter not working..
Hi guyz im a newbie to VB programming hope u can help me with this.
My problem is that i want to filter my database by date but i guess there is something wrong with my coding. It is not Filtering my database according to the range I set by using 2 DTPicker.
Im using Access as database
Provider = Microsoft.JET.OLEDB.4.0
Operating Sys = XP
'My code:
Option Explicit
Public cn As ADODB.Connection
Public rs As ADODB.Recordset
Dim SQL As String
-------------------------------------------------------------------------
Private Sub cmdExit_Click()
Unload Me
End Sub
-------------------------------------------------------------------------
Private Sub cmdSearch_Click()
Set cn = New ADODB.Connection
With cn
.Provider = "Microsoft.Jet.OLEDB.4.0"
.ConnectionString = "Data Source = " _
& App.Path & "\database\log.mdb ;Persist Security Info=False"
.CursorLocation = adUseClient
.Open
End With
Set rs = New ADODB.Recordset
DataGrid.Refresh
SQL = "SELECT EM_ID, DATE_LOG FROM TIMELOG WHERE DATE_LOG BETWEEN ' " & DTPicker1 & " ' and ' " & DTPicker2 & " ' "
rs.CursorLocation = adUseClient
rs.Open SQL, cn, adOpenDynamic, adLockBatchOptimistic
Set DataGrid.DataSource = rs
End Sub
-------------------------------------------------------------------------
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|