Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

import excel into access 1

Status
Not open for further replies.

cthai

Technical User
Apr 19, 2011
53
US
Hello -
I have a situation where I need to “import” an excel file into access but the file name constantly change. Is there a way I can import the file by the date? The file come in as ‘report20110419052731.xls’ the 20110419 is the date stamp. If this is not a good option – is there a way to create a button and when a user click on it they can choice the file they want to import?

any suggestion? thanks you
 
What is your actual code to import the excel file ?

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
this is the code i currently use and it does import the data to the table - but i have to change the report name everyday. i would like the code to pick the lastest xls from dailyreport folder and import it into Report table.
Code:
DoCmd.SetWarnings False
DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel9, "Report", "C:\dailyreport\'report20110419052731.xls'  ", True

 
Replace this:
"C:\dailyreport\'report20110419052731.xls' "
with this:
"C:\dailyreport\" & Dir("C:\dailyreport\'report" & Format(Now, "yyyymmdd") & "*.xls'")

BTW, you really have single quotes in the pathname ?

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Thanks PHV!

that works wonderful!

sorry - it was a typo :) there is no single quotes in the pathname...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top