Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

I need help importing data in Access 2013

Posted on 2014-11-21
3
Medium Priority
?
979 Views
Last Modified: 2014-12-14
Hello Experts,
I need help with a feature I need implemented to an Access 2013 application.
I am developing a scheduling app.  The staff members email me their availability on a spreadsheet.  
I then save those spreadsheet to a specific folder in my C drive (C:\Schedules\).

I have a table in Access 2013 where I save the data in the spreadsheets into.  This is tedious work.

I want to create a form in Access 2013 with just 1 button, that will read all the files in the C:\Schedules directory.
And import the information into my schedules table.

Image of what my C:\Schedules directory
Directory.jpg
Here is a sample of the information that the spreadsheets contain:

USER ID            DATE_AVAILABLE            EMAIL            PHONE
100001            11/1/2014            me@test.com      111-112-2233
100001            11/2/2014            me@test.com      111-112-2233
100001            11/9/2014            me@test.com      111-112-2233
100001            11/12/2014            me@test.com      111-112-2233
100001            11/13/2014            me@test.com      111-112-2233
100001            11/14/2014            me@test.com      111-112-2233      


My tblSchedules table in Access has the same fields:
USER ID            DATE_AVAILABLE            EMAIL            PHONE


How can I do this?  Thank you in advance for all of your help.


mrotor
0
Comment
Question by:mainrotor
  • 2
3 Comments
 
LVL 85

Accepted Solution

by:
Scott McDaniel (Microsoft Access MVP - EE MVE ) earned 2000 total points
ID: 40457827
You can use the DIR function to loop through a directory and get the contents:

Dim sFile As String
sFile = Dir("C:\Schedules", "*.xls")

Do Until Len(sFile) = 0
  DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel9, "Table", "C:\Schedules\" & sfile
  Dir
Loop

Personally, I'd import to a "staging" table first, then use VBA/SQL to move the new data into the "live" table. This would allow for you to insure you have clean data.

Also, if your file extension isn't ".xls", change the Dir command to reflect the correct extension.
0
 

Author Comment

by:mainrotor
ID: 40458620
Thanks for your reply Scott,
I will try your suggestion over the weekend and post my results.  Thanks.

mrotor
0
 

Author Comment

by:mainrotor
ID: 40477900
Hi Scott McDaniel,

I tried your code but I got a Type Mismatch error.  I have attached an image of the error.  How can I fix this?
Thanks in advance.

mrotorType mismatch errorType mismatch error
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
Microsoft Access has a limit of 255 columns in a single table; SQL Server allows tables with over 255 columns, but reading that data is not necessarily simple.  The final solution for this task involved creating a custom text parser and then reading…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …

886 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question