Solved

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

Posted on 2011-09-21
4
292 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 47

Accepted Solution

by:
Dale Fye (Access MVP) earned 250 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 47

Expert Comment

by:Dale Fye (Access MVP)
ID: 36573583
Oops, also take a look at:

Print #
0
 
LVL 92

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 92

Expert Comment

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

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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 …
This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
The viewer will learn how to simulate a series of coin tosses with the rand() function and learn how to make these “tosses” depend on a predetermined probability. Flipping Coins in Excel: Enter =RAND() into cell A2: Recalculate the random variable…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

726 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