?
Solved

Create basic text file based on a field on an Access Form

Posted on 2011-09-21
4
Medium Priority
?
303 Views
Last Modified: 2012-05-12
I want to take the contents of a form field and create a text file on the file system that has only the contents of this field in them.

I don't want to use TransferText as I'm not exporting a table or query or any structured data.

Basically, just create a blank file, insert the contents of the form field and then save it....

How is this done throughVBA?
0
Comment
Question by:macecase
  • 2
  • 2
4 Comments
 
LVL 49

Accepted Solution

by:
Dale Fye earned 1000 total points
ID: 36573580
Take a look at the Access Help on the following topics:

Open
Write #
Close

The syntax looks like:

Open "filename" for Output as #1

Write #1, "Hello World"    

Close #1
0
 
LVL 49

Expert Comment

by:Dale Fye
ID: 36573583
Oops, also take a look at:

Print #
0
 
LVL 93

Expert Comment

by:Patrick Matthews
ID: 36573590
A snippet like this will do:


Dim fso As Object, ts As Object

Set fso = CreateObject("Scripting.FileSystemObject")
Set ts = fso.CreateTextFile("c:\folder\subfolder\file.txt", True)
ts.WriteLine Forms![NameOfForm]![NameOfField]
ts.Close
Set ts = Nothing
Set fso = Nothing

Open in new window

0
 
LVL 93

Expert Comment

by:Patrick Matthews
ID: 36573599
Slow fingers :)
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Microsoft Office Picture Manager was included in Office 2003, 2007, and 2010, but not in Office 2013. Users had hopes that it would be in Office 2016/Office 365, but it is not. Fortunately, the same zero-cost technique that works to install it with …
Windows Explorer let you handle zip folders nearly as any other folder: Copy, move, change, and delete, etc. In VBA you can also handle normal files and folders, but zip folders takes a little more - and that you'll find here.
The viewer will learn how to  create a slide that will launch other presentations in Microsoft PowerPoint. In the finished slide, each item launches a new PowerPoint presentation and when each is finished it automatically comes back to this slide: …
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question