Importing data from excel to access

Rameez

Registered User.
Local time
Today, 22:16
Joined
Jun 5, 2009
Messages
26
I am importing a table from excel to access. It works fine...but my code has certain limitations. I am a novice in Access and Please for God sake help me out...My queries are.

1. I am hardcoding the name of the mdb file in my vba code.so if someone changes its name, it won't work. can u plz specify what I can add instead of the code below.
strConn = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & CurrentProject.Path & "\Tool.mdb;"
tool.mdb is the hardcoding...how to remove it...?????


2. I am hardcoding the location, where the excel file to be uploaded is present. so my list box populates only excel files from that location. If i want some kind of open folder icon, so that the user can select file anywhere in the computer and populate the list box with it...
strLocation = "C:\mdrr\"
Call FillList(ctl, strLocation)
I don't want to hardcode the location...the listbox should populated excel files from any location, the user choses from a open folder icon.

PLEASE HELP ME OUT....
 
wbPath = "C:\mdrr\rameez.xls"
strSQL = "Insert into tablename SELECT * FROM [Sheet1$] IN '" & wbPath & "' 'Excel 8.0;'"

I am even hardcoding the path....i want to remove this and let the user select the required file...
 

Users who are viewing this thread

Back
Top Bottom