Hi, just joined hoping for help. I've arranged the code below a zillion different ways. I had it running without error once but it pulled all the data rather than the data specified in the date criteria. I viewed the msgbox and don't see a problem with the sql but obviously there is a problem. I'm getting an error now on the where clause. I'm out of ideas and will greatly appreciate your help!
intSrtMonth = 4
intEndMonth = 6
intEndDay = 30
intYear = 2011
strSQL = "INSERT INTO [Qtrly Undup Report 2] "
strSQL = strSQL & "SELECT DISTINCT [Qtrly Dup Report 1].[PT_ID], [Qtrly Dup Report 1].[PT_SSN], [Qtrly Dup Report 1].[PT_CLTSPT_ID], "
strSQL = strSQL & "[Qtrly Dup Report 1].[PT_RACE_CD], [Qtrly Dup Report 1].[PT_SEX], [Qtrly Dup Report 1].[PT_BIRTH_DT], [Qtrly Dup Report 1].[CF_SVC_DT] "
strSQL = strSQL & "FROM [Qtrly Dup Report 1] "
strSQL = strSQL & "Where ([Qtrly Dup Report 1].[CF_SVC_DT] between #"
strSQL = strSQL & intSrtMonth & "/" & 1 & "/" & "/" & intYear
strSQL = strSQL & "# and #"
strSQL = strSQL & intEndMonth & "/" & intEndDay & "/" & "/" & intYear & "#)"
DoCmd.RunSQL (strSQL)
intSrtMonth = 4
intEndMonth = 6
intEndDay = 30
intYear = 2011
strSQL = "INSERT INTO [Qtrly Undup Report 2] "
strSQL = strSQL & "SELECT DISTINCT [Qtrly Dup Report 1].[PT_ID], [Qtrly Dup Report 1].[PT_SSN], [Qtrly Dup Report 1].[PT_CLTSPT_ID], "
strSQL = strSQL & "[Qtrly Dup Report 1].[PT_RACE_CD], [Qtrly Dup Report 1].[PT_SEX], [Qtrly Dup Report 1].[PT_BIRTH_DT], [Qtrly Dup Report 1].[CF_SVC_DT] "
strSQL = strSQL & "FROM [Qtrly Dup Report 1] "
strSQL = strSQL & "Where ([Qtrly Dup Report 1].[CF_SVC_DT] between #"
strSQL = strSQL & intSrtMonth & "/" & 1 & "/" & "/" & intYear
strSQL = strSQL & "# and #"
strSQL = strSQL & intEndMonth & "/" & intEndDay & "/" & "/" & intYear & "#)"
DoCmd.RunSQL (strSQL)