Reputation: 305
StartDate3 = Format(StartDate1, "dd/mm/yyyy hh:mm:ss")
EndDate3 = Format(EndDate1, "dd/mm/yyyy hh:mm:ss")
Dim cn As Object
Dim rs As ADODB.Recordset
Set cn = CreateObject("ADODB.Connection")
Set sqlConnect = New ADODB.Connection
Set rs = New ADODB.Recordset
sqlConnect.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source="SOURCE";Persist Security Info=False;"
cn.Open sqlConnect
rs.ActiveConnection = cn
Sql = "SELECT * FROM [tblDatabase] WHERE [Meldt Dato] BETWEEN '" & StartDate3 & "' AND '" & EndDate3 & "';"
rs.Open Sql, cn, adOpenDynamic, adLockOptimistic
With rs
End With
It gives me an error in Norwegian, so I am not sure what it would say in english, but roughly translated it says "No agreement between datatypes in expression" or something like that :p
Upvotes: 0
Views: 324
Reputation: 305
Changed code to:
Sql = "SELECT * FROM [tblDatabase] WHERE [Meldt Dato] BETWEEN #" & StartDate1 & " # AND # " & EndDate1 & " #;"
And that seemed to do it!
Upvotes: 0