vba - Linking Excel Tables in Access Gives Read-Only Error -


i have couple of excel 2010 files mapped , linked access 2010 database. need add file 3 mapped instead of two. linked excel file import , link tab under external database. seems okay. when run code re-maps excel file, gives me runtime error 3027: database or object read only. none of files or database read-only.

this code re-map files new location (ex. x-drive mail w-drive), add new excel file. should added here let me add new files?

private sub cmdacceptpath_click()  dim db dao.database dim rs dao.recordset dim strsql string dim strpath string dim strfilename string dim strsourcedb string dim strtablename string dim slist string dim gmsgboxtitle string on error goto error_handler:  docmd.setwarnings false strsourcedb = me.texcelpath.value set db = currentdb strsql = "update tblbackendfiles set setting=" & setdata(strsourcedb) & " code='sourceexcel'" docmd.runsql strsql  '-- verify linked tables refreshing strsql = "select setting, excelpath, excelrange tblbackendfiles code='sourceexcelwb'" set rs = db.openrecordset(strsql, dbopendynaset)  'open remapprogress docmd.openform "frmremapprogress"  slist = "" rs.movefirst while not rs.eof     strtablename = rs!setting     slist = slist & vbnewline & "deleting table: " & strtablename     forms!frmremapprogress.tbprogress = slist     if tableexists(strtablename)         docmd.deleteobject actable, strtablename     end if     rs.movenext wend  slist = "" '-- relink inventory database rs.movefirst while not rs.eof     slist = slist & vbnewline & "linking table: " & strtablename     forms!frmremapprogress.tbprogress = slist     forms!frmremapprogress.refresh     strtablename = rs!setting     strpath = strsourcedb & "\" & rs!excelpath     debug.print strpath     docmd.transferspreadsheet aclink, acspreadsheettypeexcel9, strtablename, strpath, true, rs!excelrange     rs.movenext wend rs.close msgbox "re-mapping excel links complete!"  goto exit_sub:  'if error occurs error_handler:     msgbox err.number & ": " & err.description, vbinformation + vbokonly, gmsgboxtitle  exit_sub: set db = nothing set rs = nothing docmd.setwarnings true  docmd.close acform, "frmremapprogress" docmd.close acform, "frmremapexcel"   end sub 

you don't need delete , recreate link excel file. close linked table (if open) , replace excel file new copy.

when open linked table, read new file.


Comments

Popular posts from this blog

javascript - gulp-nodemon - nodejs restart after file change - Error: listen EADDRINUSE events.js:85 -

Fatal Python error: Py_Initialize: unable to load the file system codec. ImportError: No module named 'encodings' -

javascript - oscilloscope of speaker input stops rendering after a few seconds -