🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.databases.ms-access
Article #13

Re: How to import multi-line record text file into Access?

#13
From: Kallal
Date: Tue, 05 Jan 1999 00:00
46 lines
2167 bytes
John, you have two approaches here. You could write a small basic program to
read two lines, and concatenate them together in to one line, and then write
this line out to a new text file. At that point you could then use and setup
the import wizard (alone with a saved spec). This method is good, since much
of the work involved in an import is "lining up" the columns in the text
file to fields in a table. Access in the above case can then do most of the
dirty work for you.

The 2nd approach would involve reading each line, and use basic to "parse"
the code, and then add a record after reading two lines.

Anyway...to read a text file in basic you do the following:

   Dim OneLine As String
   Dim fref As Integer

   fref = FreeFile()
   Open "c:\mytext.txt" For Input As fref

   Do While Not (EOF(fref))
      Input #fref, OneLine
      rem do what ever you want.......example : dispaly the line we just
read
      MsgBox (OneLine)
   Loop

close fref

Either modify the above to read 2 lines, and then write out to a new file,
or use the code to write records to a mdb as below.  If you put the two
together you can do what you want.

Dim MyDb As Database
Dim MyTable As Recordset

Set MyDb = DBEngine.Workspaces(0).Databases(0)
Set MyTable = MyDb.OpenRecordset("Table1")

   MyTable.AddNew                                 ' add a new record to
table
   MyTable![my field] = "some text"        ' assign values to a field
   MyTable.Update                                   ' write the record

Albert D. Kallal
Edmonton, Alberta Canada
kallal@msn.com
Technical Details
Message-ID: <e6DSeYOO#GA.243@upnetnews02.moswest.msn.net>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <3692698D.AE9@earthlink.net>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 1668c5,36002617d1beb0ca
X-Google-Attributes: gid1668c5,public
X-Google-Thread: ff0ac,36002617d1beb0ca
X-Google-Attributes: gidff0ac,public
From: "Kallal" <Kallal@email.msn.com>
Subject: Re: How to import multi-line record text file into Access?
Date: 1999/01/05
Message-ID: <e6DSeYOO#GA.243@upnetnews02.moswest.msn.net>
X-Deja-AN: 429124707
References: <3692698D.AE9@earthlink.net>
Newsgroups: comp.databases.ms-access,at.fido.msaccess
X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3110.3