I did not write this code at all. It is meant to compare addresses. We made some changes to the database however.
Private Sub importButton_Click()
Dim dbObj As DAO.Database, qdObj As DAO.QueryDef, sql As String, tn1 As String, tn2 As String, tn3 As String, fixed_path As String
fixed_path = export_path & "\"
Set dbObj = CurrentDb
Set qdObj = dbObj.QueryDefs("qry_Tmp") it is stating object not found in this collection.. is there a query missing?
tn1 = "current_addresses"
sql = "DELETE * FROM [" & tn1 & "] WHERE RECORD_TYPE <> 'D';"
dbObj.Execute sql
sql = "ALTER TABLE [" & tn1 & "] ADD COLUMN bad_address BIT;"
dbObj.Execute sql
sql = "UPDATE [" & tn1 & "] SET bad_address = -1;"
dbObj.Execute sql
sql = "UPDATE [" & tn1 & "] SET bad_address = Switch(" & _
"Nz(Match__cv__Mailing_Street__c, '') = '', -1," & _
"Nz(STREET_NAME_OLD, '') = '' AND Nz(__Mailing_Street__c, '') <> '', 0," & _
"Nz(STREET_NAME_OLD, '') <> '' AND Nz(__Mailing_Street__c, '') <> '', iif( Instr(__Mailing_Street__c, Nz(PRIMARY_NUMBER_OLD,'')) >0 AND Instr(__Mailing_Street__c, Nz(STREET_NAME_OLD,'')) >0 AND Instr(__Mailing_Street__c, Nz(SECONDARY_NUMBER_OLD,'')) >0, -1, 0));"
dbObj.Execute sql
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel12Xml, tn1, fixed_path & "ereturns.xlsx"
qdObj.Close
Set qdObj = Nothing
Set dbObj = Nothing
End Sub