[AccessD] Access 2002 SQL problem

Johncliviger at aol.com Johncliviger at aol.com
Sat Oct 3 05:14:01 CDT 2009


Hi all
 
I have the following SQL code snippet and it produces the incorrect number  
of records when its run by Docmd.RunSQL strSQL, but the correct number when 
run  thru Access query. No errors as raised. I've been looking at this 
problem for  several days on/off now so can anyone offer a word of wisdom?  
 
TIA
john cliviger
 
 
Public Sub LetterHistory(R As String, SD As Date, ED As Date) ' R =  report 
name, SD = Start Date, ED = End Date 
Dim strSQL As String 
On Error GoTo Flag1 
strSQL = "INSERT INTO tbl_Letter_Specs ( Refnoc, DateLetterSent,  
LetterName ) " & _ 
"SELECT tbl_PatientDetails.REFNOC, Date() AS DateLetterSent, '" & R  & "' 
AS LetterName " & _ 
"FROM tbl_PatientDetails INNER JOIN tbl_PatientSpecs ON  
tbl_PatientDetails.REFNOC = tbl_PatientSpecs.REFNOC " & _ 
"WHERE ((tbl_PatientSpecs.RP_DATE Between #" & Format(SD,  "dd/mm/yyyy") & 
"# And #" & _ 
Format(ED, "dd/mm/yyyy") & "#)AND ((tbl_PatientDetails.RecallFlag) =  0));"



More information about the AccessD mailing list