[AccessD] import text

Heenan, Lambert Lambert.Heenan at aig.com
Mon Apr 15 11:22:22 CDT 2013


" replace ff with 1" - Not recommended. Always use FreeFile. You cannot assume that file handle 1 is not in use.

All that was wrong with that part of Stuart's air code was that he wrote

FreeFile ff

When in fact it should have been

ff = FreeFile

Lambert 

-----Original Message-----
From: accessd-bounces at databaseadvisors.com [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Rocky Smolin
Sent: Monday, April 15, 2013 12:08 PM
To: 'Access Developers discussion and problem solving'
Subject: Re: [AccessD] import text

Just a WAG but what if you replace ff with 1?  On the rare occasions I've had to do this, I just used 1 instead of getting a file number from freefile.
Rocky
 

-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of pedro at plex.nl
Sent: Monday, April 15, 2013 3:37 PM
To: AccessD at databaseadvisors.com
Subject: Re: [AccessD] import text

Dear Paul, Shamil, Stuart,

i already tried several things before contacting accessd again, also Dim, with no result.

Still i get an compiling error (Syntax) at line: 

While not EOF(#ff)

and

strOutputLine = replace(strTemp(" ",strDQ & "," & strDQ)

Below the latest code version.

Anyone a idea?

Greetings

Pedro






Private Sub import()

Dim ff As Integer
Dim strTemp As String
Dim strOutputLine As String
Dim strResult As String
Dim strDQ As String
Dim strFilename As String
ff = VBA.FreeFile()
strDQ = Chr$(34)

strFilename = "C:\Temp\Test_Import.txt"

Open strFilename For Input As #ff
Line Input #ff, strTemp

While not EOF(#ff)
   If Left$(strTemp, 2) = "**" Then 'Build initial quote/comma delimited string
   strOutputLine = replace(strTemp(" ",strDQ & "," & strDQ)
   'add start and end quotes
   strOutputLine = strDQ & strOutputLine & strDQ
   End If
   
   If Left$(strTemp, 10) = "CONCLUSIE:" Then 'Get next line
       Line Input #ff, strTem
      strOutputLine = strOutputLine & "," & strDQ & strTemp & strDQ
   End If
   
   If Left$(strTemp, 10) = "DIAGNOSES:" Then 'Get next line
       Line Input #ff, strTemp
      strOutputLine = strOutputLine & "," & strDQ & strTemp & strDQ
      'and append this line
      strResult = strResult & vbCrLf & strOutput
   End If

   Line Input #ff, strTemp
Wend
Close #ff
Debug.Print strResult

End Sub
--
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com

--
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com



More information about the AccessD mailing list