importing a csv file through a form

G

Guest

Hi guys!

How do I add a "Open/ Browse file" button in a form?
I want to import a csv file through a form (but not using the "Get External
Data" button).

I'm using MS Access 2003.

Thanks!
Ron
 
M

Mike Painter

Speqter said:
Hi guys!

How do I add a "Open/ Browse file" button in a form?
I want to import a csv file through a form (but not using the "Get
External Data" button).

I'm using MS Access 2003.
Look up transferXXXXX where the XXXX is text, database, etc.
 
G

Guest

I'm sorry but I don't understand (I'm a real newbie).
Can someone please explain?
 
G

Guest

I now get it. I was able to use the DoCmd.TransferText command.

Is there a way of adding a "Browse" window so the user can scroll through
the hard disk's directories to select a file of his choice?

Thanks!
Ron
 
T

Tom

As I understand your question this is a two step process.

Firstly, you want the user to select a file using the standard Open File
dialog box.

The standard Open File dialog box is not part of Access so you need to make
an external call using a Declare statement. If you are new to Access and
writing VBA I cannot recommend trying this now. That is, unless someone here
provides you with the exact code to use.

Secondly, you want to import the file. To do this you can fx use
DoCmd.TransferText or DoCmd.TransferSpreadsheet.
 
G

Guest

Thanks Van!
But I can't get the Dialog Box to appear. [Will someone please help me make
this work? I already bought a book (but I can't find the Open File dialog box
command there), and I'm really serious in learning Access.]

What I did was I inserted a command button, and I inserted the code as an
on_click action. However, nothing happens. Can someone walk me through this?
http://www.mvps.org/access/api/api0001.htm

Thanks a lot!
Ron
 
V

Van T. Dinh

1. Copy the whole code into a Standard Module. Compile & save it.

2. Add the following code into your CommandButton_Click Event

****
Dim strTestIt As String

strTestIt = TestIt()
****

TestIt() is a function in the code posted which is used for testing.
 
G

Guest

Thanks guys!


Van T. Dinh said:
1. Copy the whole code into a Standard Module. Compile & save it.

2. Add the following code into your CommandButton_Click Event

****
Dim strTestIt As String

strTestIt = TestIt()
****

TestIt() is a function in the code posted which is used for testing.

--
HTH
Van T. Dinh
MVP (Access)



Anakin Moonwalker said:
Thanks Van!
But I can't get the Dialog Box to appear. [Will someone please help me make
this work? I already bought a book (but I can't find the Open File dialog box
command there), and I'm really serious in learning Access.]

What I did was I inserted a command button, and I inserted the code as an
on_click action. However, nothing happens. Can someone walk me through this?
http://www.mvps.org/access/api/api0001.htm

Thanks a lot!
Ron
 

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