RUNTIME ERROR 3146 PROCESSING WAS INTERUPTED DUE TO AN INTERRUPT SQL0952N....SQLSTATE=57014
You all were a huge help to me before so here I am again.
I get the error above when I get to the docmd.strSQL. My code is supposed to identify the previous quarter and then pull the named data within that range. Instead, I get the error. I included the variable assignments in case the problem is there. Thanks in advance for your help! Nikki
Set dbUNDUP = OpenDatabase("Z:\Report.mdb")
dbUNDUP.QueryTimeout = 0
' Get date range
intMonth = Month(Now())
intYear = Year(Now())
' Get Qtr
If intMonth = 1 Or intMonth = 2 Or intMonth = 3 Then
intQtr = 4
intYear = Year(Now()) - 1
intStMonth = 10
Else
If intMonth = 4 Or intMonth = 5 Or intMonth = 6 Then
intQtr = 1
intStMonth = 1
Else
If intMonth = 7 Or intMonth = 8 Or intMonth = 9 Then
intQtr = 2
intStMonth = 4
Else
If intMonth = 10 Or intMonth = 11 Or intMonth = 12 Then
intQtr = 3
intStMonth = 7
End If
End If
End If
End If
' Get ranges
If intQtr = 4 Then
intSrtMonth = 10
intEndMonth = 12
intEndDay = 31
Else
If intQtr = 3 Then
intSrtMonth = 7
intEndMonth = 9
intEndDay = 30
Else
If intQtr = 2 Then
intSrtMonth = 4
intEndMonth = 6
intEndDay = 30
Else
If intQtr = 1 Then
intSrtMonth = 1
intEndMonth = 3
intEndDay = 31
End If
End If
End If
End If
intYearb = Year(Now()) - 1
intYearc = Year(Now())
dtRange1 = CDate("10/1/" & intYearb)
dtRange2 = CDate(intEndMonth & "/" & intEndDay & "/" & intYearc)
DoCmd.RunSQL "DELETE * FROM [Qtrly Dup Report 1]"
strSQL = "INSERT INTO [Qtrly Dup Report 1]" _
& " SELECT DISTINCT PHC05_PT.[PT_ID], PHC05_PT.[PT_SSN], PHC05_PT.[PT_CLTSPT_ID], PHC05_CFS.[CF_SVC_DT], PHC05_CFS.[CF_CA_PT_ID]," _
& " PHC05_PT.[PT_RACE_CD], PHC05_PT.[PT_SEX], PHC05_PT.[PT_BIRTH_DT]" _
& " FROM (PHC05_PT INNER JOIN PHC05_CASE ON PHC05_PT.[PT_ID] = PHC05_CASE.[CA_PT_ID]) INNER JOIN PHC05_CFS ON PHC05_CASE.[CA_SEQ_NO] = PHC05_CFS.[CF_CA_SEQ_NO] AND PHC05_CASE.[CA_PT_ID] = PHC05_CFS.[CF_CA_PT_ID]" _
& " WHERE ( PHC05_CFS.[CF_SVC_DT]" _
& " BETWEEN #" & dtRange1 & "# And #" & dtRange2 & "#" _
& " AND PHC05_PT.[PT_SEX]<>' ' AND PHC05_CFS.[CF_TM_ID] Between 300000 And 309999)" _
& " ORDER BY PHC05_PT.[PT_CLTSPT_ID], PHC05_CFS.[CF_SVC_DT], PHC05_CFS.[CF_CA_PT_ID], PHC05_PT.[PT_RACE_CD], PHC05_PT.[PT_SEX]"
DoCmd.RunSQL (strSQL)
You all were a huge help to me before so here I am again.

Set dbUNDUP = OpenDatabase("Z:\Report.mdb")
dbUNDUP.QueryTimeout = 0
' Get date range
intMonth = Month(Now())
intYear = Year(Now())
' Get Qtr
If intMonth = 1 Or intMonth = 2 Or intMonth = 3 Then
intQtr = 4
intYear = Year(Now()) - 1
intStMonth = 10
Else
If intMonth = 4 Or intMonth = 5 Or intMonth = 6 Then
intQtr = 1
intStMonth = 1
Else
If intMonth = 7 Or intMonth = 8 Or intMonth = 9 Then
intQtr = 2
intStMonth = 4
Else
If intMonth = 10 Or intMonth = 11 Or intMonth = 12 Then
intQtr = 3
intStMonth = 7
End If
End If
End If
End If
' Get ranges
If intQtr = 4 Then
intSrtMonth = 10
intEndMonth = 12
intEndDay = 31
Else
If intQtr = 3 Then
intSrtMonth = 7
intEndMonth = 9
intEndDay = 30
Else
If intQtr = 2 Then
intSrtMonth = 4
intEndMonth = 6
intEndDay = 30
Else
If intQtr = 1 Then
intSrtMonth = 1
intEndMonth = 3
intEndDay = 31
End If
End If
End If
End If
intYearb = Year(Now()) - 1
intYearc = Year(Now())
dtRange1 = CDate("10/1/" & intYearb)
dtRange2 = CDate(intEndMonth & "/" & intEndDay & "/" & intYearc)
DoCmd.RunSQL "DELETE * FROM [Qtrly Dup Report 1]"
strSQL = "INSERT INTO [Qtrly Dup Report 1]" _
& " SELECT DISTINCT PHC05_PT.[PT_ID], PHC05_PT.[PT_SSN], PHC05_PT.[PT_CLTSPT_ID], PHC05_CFS.[CF_SVC_DT], PHC05_CFS.[CF_CA_PT_ID]," _
& " PHC05_PT.[PT_RACE_CD], PHC05_PT.[PT_SEX], PHC05_PT.[PT_BIRTH_DT]" _
& " FROM (PHC05_PT INNER JOIN PHC05_CASE ON PHC05_PT.[PT_ID] = PHC05_CASE.[CA_PT_ID]) INNER JOIN PHC05_CFS ON PHC05_CASE.[CA_SEQ_NO] = PHC05_CFS.[CF_CA_SEQ_NO] AND PHC05_CASE.[CA_PT_ID] = PHC05_CFS.[CF_CA_PT_ID]" _
& " WHERE ( PHC05_CFS.[CF_SVC_DT]" _
& " BETWEEN #" & dtRange1 & "# And #" & dtRange2 & "#" _
& " AND PHC05_PT.[PT_SEX]<>' ' AND PHC05_CFS.[CF_TM_ID] Between 300000 And 309999)" _
& " ORDER BY PHC05_PT.[PT_CLTSPT_ID], PHC05_CFS.[CF_SVC_DT], PHC05_CFS.[CF_CA_PT_ID], PHC05_PT.[PT_RACE_CD], PHC05_PT.[PT_SEX]"
DoCmd.RunSQL (strSQL)