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

x
?
Solved

Read text file into variable

Posted on 2010-11-30
4
Medium Priority
?
555 Views
Last Modified: 2013-03-27
i have a text file where its contents get updated. Its has just one word in it, either Active or Inactive. Currently i have the program importing the text file into a temp table and reading it off from there. instead of iimporting to a table, can i just save it to a variable? if so, how?
0
Comment
Question by:repco
[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
4 Comments
 
LVL 12

Expert Comment

by:dlan75
ID: 34242558
Hi,
you can simply read it and when it is read by Access, save it as a variable
Here are some links to help you play with text files :

http://www.databasedev.co.uk/text_files.html
http://en.allexperts.com/q/Using-MS-Access-1440/Text-Files.htm
http://www.granite.ab.ca/access/readtextfile.htm
0
 

Author Comment

by:repco
ID: 34242598
i would like an example please
0
 
LVL 7

Accepted Solution

by:
shaydie earned 1200 total points
ID: 34242829
You can use this vba code to read the first line from the text file and assign it to a variable. Paste it into a sub or function in a module or some event on a form. Change the 'FileName =' to the actual file name and path. The strVar will hold the value read from the text file.
 
nFileNum = FreeFile
FileName = "C:\PathTo\file.txt"

Open FileName For Input As nFileNum
   Line Input #nFileNum, strVar
Close nFileNum
0
 

Author Closing Comment

by:repco
ID: 34242898
Thanks!
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

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…
The Windows Phone Theme Colours is a tight, powerful, and well balanced palette. This tiny Access application makes it a snap to select and pick a value. And it doubles as an intro to implementing WithEvents, one of Access' hidden gems.
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…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

618 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