Private Sub btnImport_Click_Click() If MsgBox("Do you want to Import and Delete data?", vbYesNo) <> vbYes Then Exit Sub End If CurrentDb.Execute "delete * from [tblImportToAccess]" Dim strName As String Dim xlApp As Object Dim xlWB As Object Set xlApp = New Excel.Application With xlApp .Visible = False Set xlWB = .Workbooks.Open("C:\Users\tjohnson\Documents\Bomin\ImportToAccess.xlsx", , False) strName = "ToImport" End With Set xlWB = Nothing Set xlApp = Nothing DoCmd.TransferSpreadsheet acImport, , "tblImportToAccess", "C:\Users\tjohnson\Documents\Bomin\ImportToAccess.xlsx", True, strName & "!" MsgBox "Data has been imported. The table will now appear and need to check for accuracy.", vbInformation DoCmd.OpenTable "tblImportToAccess" On Error GoTo EH EH: If Err.Number = 2450 Then Exit Sub 'resume next 'don't know what this is for. ElseIf Err.Number <> 0 Then MsgBox "Error " & Err.Number & ": " & Err.Description End If End Sub
Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.
When asked, what has been your best career decision?
Deciding to stick with EE.
Being involved with EE helped me to grow personally and professionally.
An Experts Exchange subscription includes unlimited access to online courses.Get Started
Connect with Certified Experts to gain insight and support on specific technology challenges including:
We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE