need help with common dialog, import function

cdoyle

Registered User.
Local time
Yesterday, 16:43
Joined
Jun 9, 2004
Messages
383
Hi,

I've been searching the forum on how to create a form that will have a command button, that will allow the user to select a file. AFter selecting the file, I want it to import the file into access.

I found this method posted a few times.
http://www.mvps.org/access/api/api0001.htm

so I created the module, and on my form I have this on my button.
Code:
Dim strFilter As String
Dim strInputFileName As String

strFilter = ahtAddFilterItem(strFilter, "Excel Files (*.csv)", "*.csv")
strInputFileName = ahtCommonFileOpenSave( _
                Filter:=strFilter, OpenFile:=True, _
                DialogTitle:="Please select an input file...", _
                Flags:=ahtOFN_HIDEREADONLY)
DoCmd.TransferText acImportDelim, , "mytablehere", "strInputFileName" True
This opens the dialot, and displays only .csv files in the directory. But if I select the file and hit OK.

I get an error that strInputFileName.TXT is not valid.

How do I retrieve the path and put it into the transferTEXT command?
 
What version of Access are you using and are you using the common dialog control?

David
 
I'm using 2007, but most of the users will be using 2003.

I'm not familar with the commong dialog control, I'm just using the technique in that link, I saw it mentioned several times in the forum. Is there a easier method to do it?
 
OK, read up on the common dialog control, and that's an active X control right? I would like to avoid using that, since I've had problems with Active X's in the past. (some users not having it etc.)

In the code I used above, am I on the right track? I just want to keep the path to the file, so I can use it in my import function.
 

Users who are viewing this thread

Back
Top Bottom