🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

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

#19
From: Dev Ashish
Date: Fri, 08 Jan 1999 00:00
103 lines
3914 bytes
Hi John,

The code will work fine in Access.  This is because Access uses Visual Basic
for Applications (VBA) which is also the underlying lang. in VB.

HTH
--
Dev Ashish (Just my $.001)
---------------
The Access Web ( http://home.att.net/~dashish )
---------------

john hayes wrote in message <36950860.3D7A@earthlink.net>...
:Rick,
:
:Is this Visual Basic code?  My client does not have VB - only Access.
:Any idea how much VB would cost for a Win95 platform?  Funding is at a
:premium for this project....
:
:If possible, I would like to do this with some sort of Access macros
:or something - but I am not too familiar with Access.
:
:Thanks for the input, all!
:
:John Hayes
:aikosys@earthlink.net
:
:Rick Stone wrote:
:>
:> I have a routine that will import this.  You need to open the text
:> file and read it line by line, then append the line to your database.
:> Here's my basic function:
:>
:> Function ImportFile()
:>
:> Dim intImportFile As Integer
:> Dim strImportFile As String
:> Dim strTableName As String
:> Dim strInputLine As String
:> Dim dbs As Database
:> Dim rst As Recordset
:>
:> strImportFile = "c:\temp\temp.txt"
:> strTableName = "TempTable"
:>
:> Set dbs = CurrentDb
:> Set rst = dbs.OpenRecordset(strTableName, dbOpenDynaset)
:>
:> intImportFile = FreeFile
:> Open strImportFile For Input As #intImportFile
:>
:> Do Until EOF(intImportFile)
:>     Line Input #intImportFile, strInputLine
:>     rst.AddNew
:>     rst!Line1 = strInputLine
:>     Line Input #intImportFile, strInputLine
:>     rst!Line2 = strInputLine
:>     rst.Update
:> Loop
:>
:> Close intImportFile
:> End Function
:>
:> You need to add error checking when you're doing the Line Input
:> statements and test with your file to see if there are any extra lines
:> at the end.  Also, if there's a blank line between records, you need
:> to do an extra Line Input statement to get rid of that.
:>
:> The table "TempTable" has two fields, "Line1" and "Line2".
:>
:> If you have any questions, please respond.
:>
:> >On Tue, 05 Jan 1999 11:35:41 -0800, john hayes <aikosys@earthlink.net>
:> >wrote:
:> >
:> >>I need to import a text data file which has 2 lines per record, into
:> >>Access.  I have tried the Import Wizard, but it does not seem to
support
:> >>multi-line records.  I see that you can save/load a format spec
:> >>for a file, but I didn't see if it saves the spec in a file that
:> >>I can manipulate (or create from scratch) - it seems to save the spec
:> >>internally?  Also, I don't know the syntax requirements for such a
:> >>spec file (not in the book).
:> >>
:> >>Can anyone tell me how to tell Access that it needs to load multi-line
:> >>records from a text file?  BTW - editing the text file to make single-
:> >>line records is not an option, since the data file is created that
:> >>way by a canned vendor module and will have to be loaded periodically
:> >>on-going.
:> >>
:> >>Also, is there a way to import without going through the Wizard?
:> >>
:> >>Thanks!
:> >>
:> >>John Hayes
:> >>aikosys@earthlink.net
:> >>
:> >
:>
:> Richard L. Stone
:> Healthcare-ID
:> rstone@fenris-inc.com
:
Technical Details
Message-ID: <773k62$q1d@bgtnsc02.worldnet.att.net>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <3692698D.AE9@earthlink.net> <3693e598.165513234@news.erols.com> <3694cd52.160243566@news.flash.net> <36950860.3D7A@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: "Dev Ashish" <dash10@hotmail.com>
Subject: Re: How to import multi-line record text file into Access?
Date: 1999/01/08
Message-ID: <773k62$q1d@bgtnsc02.worldnet.att.net>
X-Deja-AN: 430003078
References: <3692698D.AE9@earthlink.net> <3693e598.165513234@news.erols.com> <3694cd52.160243566@news.flash.net> <36950860.3D7A@earthlink.net>
X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3110.3
Organization: AT&T WorldNet Services
Newsgroups: comp.databases.ms-access,at.fido.msaccess