Hi Friends,

Need help from you all for the below mentioned Query.
When i am trying to extract data in excel from acess, I am getting a "Data Mismatch error". Can you suggest what is causing this.

There are 4 fields in access table Name (text), Date (date/time), Locatin(text) and Sr No.

Sub testcon()
Dim conn As ADODB.Connection
Dim rec As ADODB.Recordset
Dim path As String
Dim strsql As String
Dim wks As Worksheet
Dim startdate As String, enddate As String

Set conn = New ADODB.Connection
Set rec = New ADODB.Recordset
Set wks = ThisWorkbook.Worksheets("Sheet1")
path = ThisWorkbook.path & "\" & "db1.mdb"

wks.Range("A2:E800").ClearContents



'strsql = "Select * from cust_tbl"

strsql = "SELECT * FROM cust_tbl where Date>='" & wks.Range("f2") & "' and Date<='" & wks.Range("g2") & "' and Locatin = """ & wks.Range("h2") & """;"

conn.Open "Provider=Microsoft.Jet.Oledb.4.0; " & "Data Source =" & path & ";"

rec.Open strsql, conn
Sheet1.Select

wks.Cells(2, 1).CopyFromRecordset rec

conn.Close
Set conn = Nothing


End Sub
Your help much appreciated.