Good afternoon
I can pull data from access into a tab on excel currently without using a date specific period. But I now need to add the date part in and I seem to be pulling no data through and I am unsure why.
The only issue I can see is that the "table1.[Survey Completion Date & Time]" date format is "General Date - dd/mm/yyyy hh:mm:ss" and I have chaned the date1 type to "DD/MM/YYYY HH:MM:SS" and it doesnt pull data through. If I remove the date part I get data dropping into my A10 area.
Any ideas as I feel as though I am going round in circles.
thanks in advance
Gavin
I can pull data from access into a tab on excel currently without using a date specific period. But I now need to add the date part in and I seem to be pulling no data through and I am unsure why.
The only issue I can see is that the "table1.[Survey Completion Date & Time]" date format is "General Date - dd/mm/yyyy hh:mm:ss" and I have chaned the date1 type to "DD/MM/YYYY HH:MM:SS" and it doesnt pull data through. If I remove the date part I get data dropping into my A10 area.
Any ideas as I feel as though I am going round in circles.
Code:
NType = ThisWorkbook.Sheets("Loader").Range("B10").Value
date1 = Format(ThisWorkbook.Sheets("sheet1").Range("C5").Value, "DD/MM/YYYY")
date2 = Format(ThisWorkbook.Sheets("sheet1").Range("C6").Value, "DD/MM/YYYY")
If NType = "NPS" Then
mysqlst = "SELECT table1.CaseID, table1.[Case Status], " & _
"table1.[Assigned To], table1.[Date Assigned], " & _
"table1[Call Date 1] FROM table1 WHERE (table1.NPS='" & NType & "') And ((table1.[Survey Completion Date & Time]) between " & Chr(35) & date1 & Chr(35) & " AND " & Chr(35) & date2 & Chr(35) & ");"
End If
Set cn = New ADODB.Connection
With cn
.ConnectionString = con1
.Open
End With
Set rs = New ADODB.Recordset
rs.Open mysqlst, cn, adOpenDynamic, adLockPessimistic
ThisWorkbook.Sheets("Sheet1").Range("A10").CopyFromRecordset rs
rs.Close
Set rs = Nothing
cn.Close
Set cn = Nothing
thanks in advance
Gavin