Hi,
To avoid any problem, always format your date(s) to avoid problem
"SELECT [Date], [Part No], [Batch Qty] FROM [" & TableName & "] " & _
" WHERE ( END_DATE BETWEEN '" & Format(sDate, "dd-mmm-yyyy") & "' AND '"
& Format(DateAdd("m", 2, sDate), "dd-mmm-yyyy") & "' ) , cn, , , adCmdText
I did take the table name out from the second line. the date range is date 1
and date 1 + 2 months
HTH
Regards
Jean-Yves
"gti_jobert" wrote
in message ...
Hi all,
Long winded title for this one!
Got another problem with my SQL Query after connecting from VBA Excel
via ADO to MS Access. I'm hoping someone in here might have an
incling...
Code:
--------------------
.Open "SELECT [Date], [Part No], [Batch Qty] FROM [" & TableName & "] " &
_
" WHERE [" & TableName & "].[Date] LIKE '" & sDate & "'", cn, , ,
adCmdText
--------------------
sDate is declared as a date and the above statement performs as it
should, but i'm getting an error 'Data Type Mismatch in Criteria
Expression' when I change my statement from LIKE to =, example;
Code:
--------------------
.Open "SELECT [Date], [Part No], [Batch Qty] FROM [" & TableName & "] " &
_
" WHERE [" & TableName & "].[Date] = '" & sDate & "'", cn, , , adCmdText
--------------------
I need to be able to perform a BETWEEN statement on the date and this
does not work either producing the same error message. Anyone have any
ideas why this is happening?
TIA....Any Ideas Appeciated!
--
gti_jobert
------------------------------------------------------------------------
gti_jobert's Profile:
http://www.excelforum.com/member.php...o&userid=30634
View this thread: http://www.excelforum.com/showthread...hreadid=529937