File I/O with VBA in Access 2000

N

Nic

I'm looking for a good tutorial on how to write some code to generate a text
file. I've used the FileSystemObject in the Microsoft Scripting Runtime
with ASP and VBScript. Read serveral places that this isn't the prefered
method for doing files in Access.

Does anyone have a good web site with a tutorial on File I/O with VBA?

Thanks!

-Nic
 
D

Douglas J. Steele

There really isn't much to it: I'm not sure there would be a tutorial
anywhere.

To generate a file, you'd open the file for output, print to it (normally,
although you might write instead), then close when you're done:

Dim intFile As Integer

intFile = FreeFile()
Open "C:\My Documents\MyFile.txt" For Output As #intFile
Print #infFile, "This is the first line of text."
Close #intFile
 
L

Larry Daugherty

I just scanned the sites I thought might have a tutorial for you:
http://mvps.org/access and vbworld.com. At both places I got all kinds of
hits but didn't see anything relevant. I confess I gave up on VB World
without a rigorous search.

If you have an OLD text on any BASIC dialect it will probably have what
you want. Just brush off the cobwebs, the verbs are still the same. Also,
open Access vba HELP and look up "Writing Data to Files". Follow every link
and peruse the examples.

If you can get your hands on the VBA Developer's Handbook by Getz &
Gilbert from Sybex you'll find a useful section.

hth
 

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