Disable Import errors table in Ms Access

拜拜、爱过 提交于 2019-12-24 11:59: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


回答1:


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



回答2:


'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


来源:https://stackoverflow.com/questions/28269502/disable-import-errors-table-in-ms-access

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!