By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
458,249 Members | 1,665 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 458,249 IT Pros & Developers. It's quick & easy.

Import from File Open Dialog

P: n/a
Jim
I am trying to import a file using a file spec from the Access File
Open dialog... I have been out to
http://www.mvps.org/access/api/api0001.htm to look at the code, but
because I'm not a guru, I don't quite understand it all. I have gotten
as far as getting the File Open dialog to appear and then tell me what
file I chose, but if someone could help me understand how to take that
file I've selected and import it using my specification, I'd appreciate
it.

Nov 13 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Jim wrote:
I am trying to import a file using a file spec from the Access File
Open dialog... I have been out to
http://www.mvps.org/access/api/api0001.htm to look at the code, but
because I'm not a guru, I don't quite understand it all. I have gotten
as far as getting the File Open dialog to appear and then tell me what
file I chose, but if someone could help me understand how to take that
file I've selected and import it using my specification, I'd appreciate
it.


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Using the following code:

Dim strFilter As String
Dim strInputFileName As String

strFilter = ahtAddFilterItem(strFilter, _
"Text Files (*.txt;*.asc;*tab;*.csv)", _
"*.txt|*.asc|*.tab|*.csv")
strInputFileName = ahtCommonFileOpenSave(Filter:=strFilter, _

OpenFile:=True, _
DialogTitle:="Please select an input file...", _
Flags:=ahtOFN_HIDEREADONLY)

The file name is in the variable strInputFileName. Then use the
variable like this:

DoCmd.TransferText acImportDelimited, "SpecName", "tableName",_
strInputFileName

See the Access VBA Help article "TransferText Method" for more
information.
--
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBQnaCWoechKqOuFEgEQIFewCeOEt8OOc0VEkan4A6nr682M 0JDHcAni8o
SmFP2jlSOajrCyzMdmGSAYOF
=CJY4
-----END PGP SIGNATURE-----
Nov 13 '05 #2

P: n/a
Jim
Thanks! Works great!

Nov 13 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.