Deleting Error Import Table issues

bcurrey

Board Regular
Joined
Aug 11, 2011
Messages
110
Office Version
  1. 365
Platform
  1. MacOS
I'm using Access 2007. Most of the times when I import a file at my company, I get an error message because the item description is too long and it creates a table. I found a topic on how to delete the error tables in a macro, however I can't get it to work. Here's my code:


Code:
<code class="vb plain">Application.DisplayAlerts = </code><code class="vb keyword">False</code>
 
<code class="vb keyword">Function</code> <code class="vb plain">DeleteImportErrTables()</code>
<code class="vb keyword">Dim</code> <code class="vb plain">z </code><code class="vb keyword">As</code> <code class="vb keyword">Integer</code>
<code class="vb keyword">Dim</code> <code class="vb plain">db </code><code class="vb keyword">As</code> <code class="vb plain">DAO.Database</code>
 
<code class="vb keyword">Set</code> <code class="vb plain">db = CurrentDb</code>
<code class="vb keyword">For</code> <code class="vb plain">z = db.TableDefs.Count - 1 </code><code class="vb keyword">To</code> <code class="vb plain">0 </code><code class="vb keyword">Step</code> <code class="vb plain">-1</code>
<code class="vb keyword">If</code> <code class="vb plain">InStr(1, db.TableDefs(z).Name, </code><code class="vb string">"ImportError"</code><code class="vb plain">) > 0 </code><code class="vb keyword">Then</code>
<code class="vb plain">DoCmd.DeleteObject acTable, db.TableDefs(z).Name</code>
<code class="vb keyword">End</code> <code class="vb keyword">If</code>
<code class="vb keyword">Next</code> <code class="vb plain">z</code>
<code class="vb keyword">End</code> <code class="vb keyword">Function</code>


The error that I get says "Error Number 2950. Condition True, Arguments: DeleteImportErrTables()"

I'm a bit new at this, but I went to the "Data tools" tab on the ribbon. Clicked on Visual Basic, and then chose New - Module. I then copy and pasted the code above to the blank sheet.

Then went to Macro, and chose "RUN CODE" and told it the function name was DeleteImportErrTables ().
 
Use a Memo field.
That should hopefully solve the OP's issue.

I have a myriad of different other reasons for using such code. One of the biggest is that I have created a number of file conversion databases, and sometimed users import the wrong files in the wrong places. When this happens, it creates these error tables. Over time, there get to be quite a number of them in the database, using up space. So I use the code to keep those databases "clean".
 
Upvote 0

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.

Forum statistics

Threads
1,221,604
Messages
6,160,748
Members
451,670
Latest member
Peaches000

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top