Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2011-09-21
4
Medium Priority
?
301 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 48

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 48

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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

If you need a simple but flexible process for maintaining an audit trail of who created, edited, or deleted data from a table, or multiple tables, and you can do all of your work from within a form, this simple Audit Log will work for you.
With its various features, Office 365 can not only help you with your day-to-day business tasks, it can also do wonders for your marketing campaign.
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

610 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