Note that there are some explanatory texts on larger screens.

plurals
  1. PO"The Database Could Not Lock Table" Error when trying to close report, kill current tables tied to report
    primarykey
    data
    text
    <p>I have a report that updates from tables that export from a separate database. I have the report on a timer to requery every 5 minutes. The process that I am trying to execute is close the report, kill the tables behind the query that generates the report, import the the updated files to tables with the same names that were just killed and reexecute the query and report. I keep getting Run-time error '3211': "The Database Could Not Lock Table".</p> <p>Code is below and any help for this novice is greatly appreciated.</p> <pre class="lang-vb prettyprint-override"><code>Private Sub Report_Timer() 'Close Report DoCmd.Close acReport, "SMT Progress Report" 'Kill existing tables Set dbs = CurrentDb dbs.TableDefs.Delete ("SMT2Updated") ' error here dbs.TableDefs.Delete ("SMT3Updated") dbs.TableDefs.Delete ("SMT4Updated") dbs.TableDefs.Delete ("SMT5Updated") Set dbs = Nothing 'Import Files to Tables DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel12Xml, "SMT2Updated", "\\ct13nt003\mfg\SMT_Schedule_Files\SMT Line Progress Files\SMT2Updated.xlsx", True DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel12Xml, "SMT3Updated", "\\ct13nt003\mfg\SMT_Schedule_Files\SMT Line Progress Files\SMT3Updated.xlsx", True DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel12Xml, "SMT4Updated", "\\ct13nt003\mfg\SMT_Schedule_Files\SMT Line Progress Files\SMT4Updated.xlsx", True DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel12Xml, "SMT5Updated", "\\ct13nt003\mfg\SMT_Schedule_Files\SMT Line Progress Files\SMT5Updated.xlsx", True 'Refresh and Open Query/Report Me.Requery DoCmd.OpenReport "SMT Progress Report", acViewReport 'Export status file DoCmd.OutputTo acOutputReport, "SMT Progress Report Export Only", acFormatPDF, "\\ct13nt003\MFG\SMT Live Report\SMTLive" &amp; "_" &amp; Format(Now(), "mmddyyyy-hhmm") &amp; ".pdf", False End Sub </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload