Solved

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

Posted on 2011-09-21
4
295 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 (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 48

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

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

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

Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
I was prompted to write this article after the recent World-Wide Ransomware outbreak. For years now, System Administrators around the world have used the excuse of "Waiting a Bit" before applying Security Patch Updates. This type of reasoning to me …
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…

689 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