Disable Import errors table in Ms Access

2019-08-09 18:35发布

Just to start with , I am not a very experienced programmer in Access. Is there any way I can disable the import error tables which are auto generated by access when you import files from excel ?

The reason I want to do this is my excel file has about 4000 rows with data about different locations,now the location I have to do the reporting on is importing properly thats why I am not worried about about the import errors . Also, it only detects the error in one row and because I import the table from vba code it will keep generating this error tables and I end up with big bunch of them.

I did some research but I find answer about solving the issue by fixing the file format of import , but I failed to get the answer about how to disable them.

Appreciate if anyone can help.

EDIT :

After suggestion from @parfait following code did the trick. Any other suggestions are also welcome.

Sub dropImportError() Dim tbl_name As DAO.TableDef, str As String With CurrentDb For Each tbl_name In .TableDefs str = tbl_name.Name If InStr(str, "ImportErrors") <> 0 Then str = "DROP TABLE" & str & "" DoCmd.RunSQL str End If Next End With End Sub

2条回答
爱情/是我丢掉的垃圾
2楼-- · 2019-08-09 18:53

Just came across this issue myself, after running the import of procedure I immediately ran the following code which was saved in a stand-alone Module. Simply paste the function DeleteImportErrors into the macro, procedure, or function.

Module code:

Public Function DeleteImportErrors()
    Dim n As Integer
    Dim db As DAO.Database

    Set db = CurrentDb
    For n = db.TableDefs.Count - 1 To 0 Step -1
    ' loop through all tables
        If InStr(1, db.TableDefs(n).Name, "ImportError") > 0 Then
        ' if table is import errors table
            DoCmd.DeleteObject acTable, db.TableDefs(n).Name
            ' delete table
        End If
    Next n
End Function
查看更多
叼着烟拽天下
3楼-- · 2019-08-09 19:05

'Delete Import Error tables

Private Sub Delete_Error_Tables()
    Do Until IsNull(DLookup("Name", "Msysobjects", "Name like '*ImportErrors*'"))
        DoCmd.DeleteObject acTable, DLookup("Name", "Msysobjects", "Name like '*ImportErrors*'")
    Loop
End Sub

查看更多
登录 后发表回答