Browsing to find an import file

B

Brian

Hello. I am wondering if it's possible to write code so
that when you click an import button on a form, a file
browser window pops up and lets you find the file you
wish to import, such as an excel spreadsheet. Then,
after you select the file, it would save the path to your
file in a string, FileLocation, allowing you to use it in
some code, such as:

Sub ImportSpreadsheet(FileLocation As String)
DoCmd.TransferSpreadsheet _
TransferType:=acImport, _
SpreadsheetType:=acSpreadsheetTypeExcel9, _
TableName:="tblImport", _
FileName:=FileLocation, _
HasFieldNames:=True

End Sub

This way I would not have to hard code a location for
FileName property. Thanks for any help!

Brian
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top