access vba - VBA code does not work in some versions of Office, works in others -


number of query values , destination fields not same. debug redirects me line: dbs.execute strsql, dbfailonerror

here code:

public function getmatches(column1 string, column2 string)      dim dbs dao.database     dim rcrdstcolumn1 recordset     dim rcrdstcolumn2 recordset     dim defaulttable1 string     dim defaulttable2 string     dim strsql string     dim strsqlcolumn1 string     dim strsqlcolumn2 string     dim firstcurrentvalue string     dim secondcurrentvalue string     dim currentresultcomparison double     dim maxresultcomparison double      dim checkcolumn1 boolean     dim checkcolumn2 boolean      set dbs = currentdb      defaulttable1 = "cee_names_for_cust_des"     defaulttable2 = "gsndg_names"      'check  if column exists in table 1     checkcolumn1 = checkcolumn(column1, defaulttable1)     checkcolumn2 = checkcolumn(column2, defaulttable2)      if checkcolumn1 = false         msgbox ("column 1  not exist")     elseif checkcolumn2 = false         msgbox ("column 2 not exist")     else         strsqlcolumn1 = "select " & column1 & "  " & defaulttable1 & "  ;"         set rcrdstcolumn1 = dbs.openrecordset(strsqlcolumn1)          strsqlcolumn2 = "select " & column2 & " " & defaulttable2 & "  ;"           while not rcrdstcolumn1.eof             firstcurrentvalue = rcrdstcolumn1.fields(column1)             maxresultcomparison = 0              set rcrdstcolumn2 = dbs.openrecordset(strsqlcolumn2)              while not rcrdstcolumn2.eof                 secondcurrentvalue = rcrdstcolumn2.fields(column2)                  currentresultcomparison = modsimil.simil(firstcurrentvalue, secondcurrentvalue)                  strsql = "insert results(column1, column2, similarities)" _                         & " values( '" & clearstring(firstcurrentvalue) & "', '" & clearstring(secondcurrentvalue) & "', " & round(currentresultcomparison, 2) & " )"                 dbs.execute strsql, dbfailonerror                  if currentresultcomparison > maxresultcomparison                     maxresultcomparison = currentresultcomparison                 end if                  rcrdstcolumn2.movenext             loop             rcrdstcolumn1.movenext         loop      end if      dbs.close     set dbs = nothing  end function  function checkcolumn(strcolumn string, strtable string) boolean on error goto checkcolumnerror     if (dcount(strcolumn, strtable) = 0)         checkcolumn = false     else         checkcolumn = true     end if  checkcolumnerror:     if err.number = 2741         msgbox ("2741")     elseif checkcolumn         checkcolumn = true     else         checkcolumn = false     end if  end function  function clearresult()     dim dbs dao.database     dim strsql string      set dbs = currentdb      strsql = "delete results"     dbs.execute strsql, dbfailonerror      dbs.close     set dbs = nothing end function  function clearstring(str string) string     clearstring = replace(str, "'", "")   end function 


Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -