We help IT Professionals succeed at work.
Get Started

Need code to import file from excel into Access DB

Rachel asked
Last Modified: 2018-02-02
I have the code to import a static file, but what I'd like to do is create code that will look to the folder that the DB resides in and import the excel file in that folder.  I will be copying this DB multiple times for different clients and the import should look to the folder for whatever client the DB is in (I will use the same excel file name each time.)

Here's the folder structure:

Client 1 (folder name)
    AccessDB_Client1 (access db name - could be any name)
    Source Files (folder name)
        tblPolicy.xls (file name)

    AccessDB_Client2 ( (access db name - could be any name)
    Source Files (folder name)
        tblPolicy.xls  (file name)

So if the Access DB is client 1 or client 2 (or any client folder for that matter), the import file will look to the appropriate folder and import the tblPolicy.xls that applies to that client in the Access DB that is also in that client's folder.

Here's the code I'm already using.

Happy to pay for live help as well!

Private Sub cmdImportUsers_Click()

Dim Response As Integer
Response = MsgBox("You are about to import user data which will overwrite any existing manually changes you've made in this system.  Are you sure you want to continue?", vbYesNo)
If Response = vbYes Then
DoCmd.SetWarnings False
DoCmd.OpenQuery "z_qry_Delete_z_tbl_TAM_Users"
DoCmd.RunSavedImportExport "Import-z_tblSourceEmployees"
DoCmd.SetWarnings True
MsgBox "Users Imported Successfully"
MsgBox "Users have not been imported"

End If

End Sub
Watch Question
Distinguished Expert 2017
This problem has been solved!
Unlock 3 Answers and 5 Comments.
See Answers
Why Experts Exchange?

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.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE