cheekybuddha
AWF VIP
- Local time
- Today, 10:43
- Joined
- Jul 21, 2014
- Messages
- 3,201
rsFilesFound is an odd name for a table or query!Try:
Code:
Dim strMsg As String
Dim strSql As String
If Not Me.chkDir Then
'SQL below is to count all records not found in active directory search
strSql = "SELECT COUNT(*) " & _
"FROM tblClips c LEFT JOIN rsFilesFound ff ON c.fldLocation = ff.fldFileAddress " & _
"WHERE c.blnAlive = True AND ff.fldFileAddress IS NULL;"
With CurrentDb.OpenRecordset(strSql)
strMsg = "The SQL Query contains " & .Fields(0) & " references."
.Close
End With
If MsgBox(strMsg, vbOKCancel, "TESTING") = vbCancel Then Exit Sub
strSQL = "UPDATE tblClips c1 " & _
"SET c1.blnAlive = False " & _
"WHERE c1.ID IN (" & _
"SELECT c2.ID " & _
"FROM tblClips c2 LEFT JOIN rsFilesFound ff ON c2.fldLocation = ff.fldFileAddress " & _
"WHERE c2.blnAlive = True AND ff.fldFileAddress IS NULL" & _
");"
CurrentDb.Execute strSQL, dbFailOnError
End If