Solved

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

Posted on 2011-09-21
4
258 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 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
PaperPort has a feature called the "Send To Bar". It provides a convenient, drag-and-drop interface for using other installed software, such as Microsoft Office. However, this article shows that the latest Office 2016 apps (installed with an Office …
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

747 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now