ahhh, bolei um esquema legal de validação, junto com pessoal do trampo, segue abaixo.
grato por quem visitou o tópico.
-----
Private Sub Consistencia_t53_t52()
On Error GoTo Handle_Error
Dim objRS As ADODB.Recordset 'Objeto de recordset
Dim strSQL As String 'String com código SQL
'Criar tabelas temporárias, só para esta consistência
strSQL = "select codigo into tabela_053_t from tabela_053"
Call g_objConexaoAccess.Execute(strSQL)
strSQL = "select codigo into tabela_052_t from tabela_052"
Call g_objConexaoAccess.Execute(strSQL)
'Fazer a consistência
strSQL = "delete from tabela_053_t where codigo in (select codigo from tabela_052_t)"
Call g_objConexaoAccess.Execute(strSQL)
strSQL = "select codigo from tabela_053_t where codigo is not null"
Set objRS = New ADODB.Recordset
Call objRS.Open(strSQL, g_objConexaoAccess, adOpenForwardOnly, adLockReadOnly, adCmdText)
If Not objRS.EOF Then
While Not objRS.EOF
'Grava o log com problemas - NOK
strSQL = "insert into log_consistencia(consistencia,campo,valor,observacao) " _
& "values('TABELA053->TABELA052','codigo','" & Val(objRS("codigo")) & "','Consistência NOK')"
Call g_objConexaoAccess.Execute(strSQL)
objRS.MoveNext
Wend
ElseIf objRS.EOF Then
'Grava o log sem problemas - OK
strSQL = "insert into log_consistencia(consistencia,campo,valor,observacao) " _
& "values('TABELA053->TABELA052','','','Consistência OK')"
Call g_objConexaoAccess.Execute(strSQL)
End If
Set objRS = Nothing
'Apagar tabelas temporárias
strSQL = "drop table tabela_053_t"
Call g_objConexaoAccess.Execute(strSQL)
strSQL = "drop table tabela_052_t"
Call g_objConexaoAccess.Execute(strSQL)
Exit Sub
Handle_Error:
If Err.Number = -2147217865 Then 'Table 'xxxxx' does not exist.
Resume Next
Else
MsgBox "Erro: " & Err.Number & vbCrLf & Err.Description, vbCritical, "frmConsistencia / Consistencia_t53_t522"
End If
End Sub