Solved

Read text file into variable

Posted on 2010-11-30
4
538 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 300 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

Independent Software Vendors: 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

AutoNumbers should increment automatically, without duplicates.  But sometimes something goes wrong, and the next AutoNumber value is a duplicate.  This article shows how to recover from this problem.
Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

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