Allow user to sellect *.* files to import

G

Guest

I have a file that arrives each day into a folder from an ftp site. Each
file has a different filename.

I want to create a command button that allows the user to browse for that
file, select it and for the code to then import the file (it will be a .tab
file) into an existing access 2003 table.

I know that I can create a macro using the transfertext command, but I need
to know how to allow the user to browse to the file before the import. Do I
need VB code or is there another way? I am new to VB code, but not new to
basic access development.

Thanks in advance.
 
D

David Lloyd

The FileDialog object is one alternative to allow a user to browse for and
select a file. The following KB article gives more information on how to
use the FileDialog object.

http://support.microsoft.com/default.aspx?scid=kb;en-us;824272

Another alternative is to use the Common Dialog control. It is similar to
the FileDialog object, however, I prefer the FileDialog object when it meets
the requirements.

--
David Lloyd
MCSD .NET
http://LemingtonConsulting.com

This response is supplied "as is" without any representations or warranties.


I have a file that arrives each day into a folder from an ftp site. Each
file has a different filename.

I want to create a command button that allows the user to browse for that
file, select it and for the code to then import the file (it will be a .tab
file) into an existing access 2003 table.

I know that I can create a macro using the transfertext command, but I need
to know how to allow the user to browse to the file before the import. Do I
need VB code or is there another way? I am new to VB code, but not new to
basic access development.

Thanks in advance.
 
G

Guest

David,

This looks like exactly what I wanted, but I must apologize. I told you
access 2003, but I am actually still on 2000. I did a search for your
article for access 2000 and couldn't find it. And when I use the code in
that article I get the following VB error:

'compile error: User Defined Type not Defined'

Please help again!
 
M

Mike Painter

BLTibbs said:
I have a file that arrives each day into a folder from an ftp site.
Each file has a different filename.

I want to create a command button that allows the user to browse for
that file, select it and for the code to then import the file (it
will be a .tab file) into an existing access 2003 table.

I know that I can create a macro using the transfertext command, but
I need to know how to allow the user to browse to the file before the
import. Do I need VB code or is there another way? I am new to VB
code, but not new to basic access development.

Thanks in advance.
Others have shown how to browse, but if you delete the file when done with
it and use Dir() to get the new filename, it could be done completely
automatically or with a yes/no option given to the user.
 
D

David Lloyd

My recollection is that the FileDialog object was introduced with Access
2002, which is why you are receiving the error message in Access 2000. As I
mentioned, you can use the Common Dialog control, and this is supported in
Access 2000. Below are some KB articles on using this control.

http://support.microsoft.com/default.aspx?scid=kb;en-us;161286
http://support.microsoft.com/default.aspx?scid=kb;en-us;155980

--
David Lloyd
MCSD .NET
http://LemingtonConsulting.com

This response is supplied "as is" without any representations or warranties.


David,

This looks like exactly what I wanted, but I must apologize. I told you
access 2003, but I am actually still on 2000. I did a search for your
article for access 2000 and couldn't find it. And when I use the code in
that article I get the following VB error:

'compile error: User Defined Type not Defined'

Please help again!
 
M

Mike Painter

This is right out of the help file:
' Returns filename with specified extension. If more than one *.ini
' file exists, the first file found is returned.
MyFile = Dir("C:\WINDOWS\*.INI")

' Call Dir again without arguments to return the next *.INI file in the
' same directory.
MyFile = Dir

If you only have the one file then you are done with
MyFile = Dir("C:\WINDOWS\*.INI")
and you would use MyFile with TransferText or whatever.
 

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