I have created a application that takes an Excel file and inserts it into my access database table. I used Microsoft Access 15.0 Object Library in my computer . But when I executed the application it in an another computer with Access 2007 it stops immediately. This is the code:
Private Sub xlsTomdb()
On Error GoTo err_handler
Dim oAccess As Access.Application
Set oAccess = CreateObject("Access.Application")
oAccess.Visible = False
oAccess.OpenCurrentDatabase App.Path + "\archivi.mdb", True
oAccess.DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel8, "EXCEL", App.Path + "\Export\Final.xls", True
oAccess.Quit
err_handler:
MsgBox "The code failed at line " & Erl, vbCritical
End Sub
The msgBox shows "The code failed as line 0". When I removed the Error Handler the program continues the execution normally. While running the program on another PC with Office 2007 it terminates at this function with runtime error [-2147467259 (80004005) microsoft odbc microsoft access driver type mismatch in expression]
This function is executed on button click event. Is there any reason not to open access 2007, because I used Access 2013 while building it?
Can anyone help?
Dim oAccess As Object
instead ofDim oAccess As Access.Application
– Gord Thompson