importing text strings

rik

Registered User.
Local time
Today, 14:02
Joined
Jan 14, 2008
Messages
17
hi guys,

i am importing a tab seperated file into a table, and one of the fields is a user comment.

all is well -- until a record is imported that contains comment with a carriage return followed by some more text. the text after the carriage return is imported as the next record.

if the file is tab seperated, why is the carriage return causing the import to act in this way?

thanks

rik.
 
hi guys,

i am importing a tab seperated file into a table, and one of the fields is a user comment.

all is well -- until a record is imported that contains comment with a carriage return followed by some more text. the text after the carriage return is imported as the next record.

if the file is tab seperated, why is the carriage return causing the import to act in this way?

thanks

rik.

Access interprets carriage return as the end of line marker regardless of where it occurs. If this is a one time deal you can open the file and remove the offending carriage returns manually, if this will be a recurring import you may need to look at using VBA to open the file and read it in manually, this is less convenient than the transfer text method, but gives you a lot more control.
 
thanks, so how would i do this? with a button on a form, with VBA code behind it?

i do have one concern about this method... how do i differentiate between a carriage return in the text field, and the actual one marking the end of the record?

thanks
rik.
 
thanks, so how would i do this? with a button on a form, with VBA code behind it?

i do have one concern about this method... how do i differentiate between a carriage return in the text field, and the actual one marking the end of the record?

thanks
rik.

A button works if you want this to be started manually, or you could use a macro that calls a function, or the autoexec macro so it runs when the database is opened...any number of methods to run the code would work.

To your second point that is where it gets a little tricky, but if it were me I would check for a Carriage Return followed by a line feed, that should be the real end of line.
 
thanks,

any ideas of where to find code that reads in a file, checks each character and ... well i could program the rest!

rik.
 
thanks,

any ideas of where to find code that reads in a file, checks each character and ... well i could program the rest!

rik.

well you could search the forum, I'm sure there are some examples, you'd probably want to look for the Open <filename> for Input As <fileNumber> method.

Real basic method to read in a file one character at a time.

Code:
Dim st As String, fh As Double

fh = FreeFile

Open "c:\Test.txt" For Input As fh
    Do Until EOF(fh)
        st = Input(1, fh)
    Loop
Close fh
 
thanks for the help.

i need to perform a basic import (as the wizard will let me), but just remove any solitary line feed characters prior to this.

i have started programming this, but it seems like a very big job. is it possible to read in the file one character at a time, remove solitary LF characters, then call a generic import function **on the resulting string** (not an output file. otherwise i seem to have to rewrite access' import function, which seems re-inventing the wheel.

docmd.transfertext seems to do this, but whaton earth does 'specificationName' as a parameter mean? it seems like i have to create a seperate spec file (??). can i hard-code the spec, as it'll always be a tab-seperated import.

any thoughts?

rik.
 
Last edited:

Users who are viewing this thread

Back
Top Bottom