How to get text file text into variables?

  • Thread starter Thread starter Renee
  • Start date Start date
R

Renee

Guest
I have text files with the following format:

column1 = value 1
column2 = value 2
column3 = value 3
etc.

I don't know the name of this file format but I have heard that it is Microsoft friendly.

I'd like to be able to parse through the text file, looking for 'column 2' for example, then get the value for column 2 and store it in a variable (that would then display on a form and if the user accepts it get saved to a table.)

In another software program (Wonderware) we used a function called INIReadString to do this. I haven't been able to figure out how Access/VBA handles this but I am hoping that there is some way.

I'd greatly appreciate any help or ideas of where else to look for help.​
 
Access allows you to link to external text files or you can import them manually or in code by using the transfertext Action or Method.

If the text file is a comma delimited format, you probably won't need an import spec. format example:

NameOfFirstField,NameOfSecondField,NameOfThirdField,etc.
ValueOfFirstField,ValueOfSecondField,ValueOfThirdField,etc.
ValueOfFirstField,ValueOfSecondField,ValueOfThirdField,etc.
ValueOfFirstField,ValueOfSecondField,ValueOfThirdField,etc.
etc.

[This message has been edited by Pat Hartman (edited 02-05-2000).]
 
I ended up with a good solution to my problem. I set the delimiter as an = sign and it splits the name and the value into two columns when I import the file. Then I can find each name and get the value in the next column and save it to a variable then carry on from there. By the way, I found out the file format is called .ini
 

Users who are viewing this thread

Back
Top Bottom