By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
428,978 Members | 1,492 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 428,978 IT Pros & Developers. It's quick & easy.

Using a Text file with Long Rows as an Input Data Source

P: n/a
I have a text file from a text document that has very long rows (two
or three paragraphs from a text document for each row). Importing to
text cuts it off at 255 characters, and importing to a memo still cuts
it short. TransferText cut it short too. Someone suggested that I
use the following code. It works, but it populates only one row of
the text. Missing something critical.

Any ideas on how to get this to work?

'Beginning of code ***************
Public Function PopText()
Dim rst1 As ADODB.Recordset
Dim longStr As String
Dim f1 As Long
Set rst1 = New ADODB.Recordset
rst1.Open "TFERraw", CurrentProject.Connection, adOpenKeyset,
adLockOptimistic

Open "C:\Documents and Settings\Bob\Desktop\TFER2\TFER1.txt" For Input
As #1

Do While Not EOF(1)
rst1.AddNew
f1 = LOF(1)
longStr = Input(f1, #1)
rst1("Text1") = longStr
rst1.Update
Loop

Close #1
rst1.Close
Set rst1 = Nothing
End Function
'End of code***************
Nov 12 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
R Bolling wrote:
I have a text file from a text document that has very long rows (two
or three paragraphs from a text document for each row). Importing to
text cuts it off at 255 characters, and importing to a memo still cuts
it short. TransferText cut it short too. Someone suggested that I
use the following code. It works, but it populates only one row of
the text. Missing something critical.

Any ideas on how to get this to work?

'Beginning of code ***************
Public Function PopText()
Dim rst1 As ADODB.Recordset
Dim longStr As String
Dim f1 As Long
Set rst1 = New ADODB.Recordset
rst1.Open "TFERraw", CurrentProject.Connection, adOpenKeyset,
adLockOptimistic

Open "C:\Documents and Settings\Bob\Desktop\TFER2\TFER1.txt" For Input
As #1

Do While Not EOF(1)
rst1.AddNew
f1 = LOF(1)
longStr = Input(f1, #1)
rst1("Text1") = longStr
rst1.Update
Loop

Close #1
rst1.Close
Set rst1 = Nothing
End Function
'End of code***************


I regularly read in whole documents into memo fields with no problems...
I read line by line.

myFile = "c:\windows\temp\zzJMM.htm"
Open myFile For Input As #1
Do While Not EOF(1)
Line Input #1, myLine
If Len(myHTML) > 0 And Len(myLine) > 0 Then myHTML = myHTML &
Chr(13) & Chr(10) 'insert line feed
myHTML = myHTML & myLine
Loop
Close #1
Me![ArticleHTML] = myHTML

--
regards,

Bradley
Nov 12 '05 #2

P: n/a
I tried this, but am having difficulty scipping through the text
document. After writing the first line of text to the memo field, it
goes to the bottom of the source text. Have any suggestions? This is
my code:

Public Sub ftest()
Dim rst1 As ADODB.Recordset
Dim mychars As String
Dim fl As Long
Set rst1 = New ADODB.Recordset
rst1.Open "TFERraw", CurrentProject.Connection, adOpenKeyset,
adLockOptimistic

Open "C:\Documents and Settings\Bob\Desktop\TFER2\TFER1.txt" For Input
As #1

Do While Not EOF(1)
rst1.AddNew
fl = LOF(1) ' gets length of file
mychars = Input(fl, #1)
rst1("Text1") = mychars
rst1.Update

Loop

Close #1
rst1.Close
Set rst1 = Nothing
End Sub


"Bradley" <br*****@REMOVETHIScomcen.com.au> wrote in message news:<40******@nexus.comcen.com.au>...
R Bolling wrote:
I have a text file from a text document that has very long rows (two
or three paragraphs from a text document for each row). Importing to
text cuts it off at 255 characters, and importing to a memo still cuts
it short. TransferText cut it short too. Someone suggested that I
use the following code. It works, but it populates only one row of
the text. Missing something critical.

Any ideas on how to get this to work?

'Beginning of code ***************
Public Function PopText()
Dim rst1 As ADODB.Recordset
Dim longStr As String
Dim f1 As Long
Set rst1 = New ADODB.Recordset
rst1.Open "TFERraw", CurrentProject.Connection, adOpenKeyset,
adLockOptimistic

Open "C:\Documents and Settings\Bob\Desktop\TFER2\TFER1.txt" For Input
As #1

Do While Not EOF(1)
rst1.AddNew
f1 = LOF(1)
longStr = Input(f1, #1)
rst1("Text1") = longStr
rst1.Update
Loop

Close #1
rst1.Close
Set rst1 = Nothing
End Function
'End of code***************


I regularly read in whole documents into memo fields with no problems...
I read line by line.

myFile = "c:\windows\temp\zzJMM.htm"
Open myFile For Input As #1
Do While Not EOF(1)
Line Input #1, myLine
If Len(myHTML) > 0 And Len(myLine) > 0 Then myHTML = myHTML &
Chr(13) & Chr(10) 'insert line feed
myHTML = myHTML & myLine
Loop
Close #1
Me![ArticleHTML] = myHTML

Nov 12 '05 #3

P: n/a
Your code is telling it to read the entire file into mychars as one value.
That means you're going to be at EOF as soon as you execute it once.

Look at the differences between your code and that posted by Bradley. His
example uses Line Input #1, myLine, while yours is using mychars = Input(fl,
#1)
--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)
"R Bolling" <ro*****@hotmail.com> wrote in message
news:6e**************************@posting.google.c om...
I tried this, but am having difficulty scipping through the text
document. After writing the first line of text to the memo field, it
goes to the bottom of the source text. Have any suggestions? This is
my code:

Public Sub ftest()
Dim rst1 As ADODB.Recordset
Dim mychars As String
Dim fl As Long
Set rst1 = New ADODB.Recordset
rst1.Open "TFERraw", CurrentProject.Connection, adOpenKeyset,
adLockOptimistic

Open "C:\Documents and Settings\Bob\Desktop\TFER2\TFER1.txt" For Input
As #1

Do While Not EOF(1)
rst1.AddNew
fl = LOF(1) ' gets length of file
mychars = Input(fl, #1)
rst1("Text1") = mychars
rst1.Update

Loop

Close #1
rst1.Close
Set rst1 = Nothing
End Sub


"Bradley" <br*****@REMOVETHIScomcen.com.au> wrote in message

news:<40******@nexus.comcen.com.au>...
R Bolling wrote:
I have a text file from a text document that has very long rows (two
or three paragraphs from a text document for each row). Importing to
text cuts it off at 255 characters, and importing to a memo still cuts
it short. TransferText cut it short too. Someone suggested that I
use the following code. It works, but it populates only one row of
the text. Missing something critical.

Any ideas on how to get this to work?

'Beginning of code ***************
Public Function PopText()
Dim rst1 As ADODB.Recordset
Dim longStr As String
Dim f1 As Long
Set rst1 = New ADODB.Recordset
rst1.Open "TFERraw", CurrentProject.Connection, adOpenKeyset,
adLockOptimistic

Open "C:\Documents and Settings\Bob\Desktop\TFER2\TFER1.txt" For Input
As #1

Do While Not EOF(1)
rst1.AddNew
f1 = LOF(1)
longStr = Input(f1, #1)
rst1("Text1") = longStr
rst1.Update
Loop

Close #1
rst1.Close
Set rst1 = Nothing
End Function
'End of code***************


I regularly read in whole documents into memo fields with no problems...
I read line by line.

myFile = "c:\windows\temp\zzJMM.htm"
Open myFile For Input As #1
Do While Not EOF(1)
Line Input #1, myLine
If Len(myHTML) > 0 And Len(myLine) > 0 Then myHTML = myHTML &
Chr(13) & Chr(10) 'insert line feed
myHTML = myHTML & myLine
Loop
Close #1
Me![ArticleHTML] = myHTML

Nov 12 '05 #4

P: n/a
I could never get it to work reading in the entire file... hence why I
read in a line at a time.

Bradley

R Bolling wrote:
I tried this, but am having difficulty scipping through the text
document. After writing the first line of text to the memo field, it
goes to the bottom of the source text. Have any suggestions? This is
my code:

Public Sub ftest()
Dim rst1 As ADODB.Recordset
Dim mychars As String
Dim fl As Long
Set rst1 = New ADODB.Recordset
rst1.Open "TFERraw", CurrentProject.Connection, adOpenKeyset,
adLockOptimistic

Open "C:\Documents and Settings\Bob\Desktop\TFER2\TFER1.txt" For Input
As #1

Do While Not EOF(1)
rst1.AddNew
fl = LOF(1) ' gets length of file
mychars = Input(fl, #1)
rst1("Text1") = mychars
rst1.Update

Loop

Close #1
rst1.Close
Set rst1 = Nothing
End Sub

"Bradley" <br*****@REMOVETHIScomcen.com.au> wrote in message
news:<40******@nexus.comcen.com.au>...
R Bolling wrote:
I have a text file from a text document that has very long rows (two
or three paragraphs from a text document for each row). Importing
to text cuts it off at 255 characters, and importing to a memo
still cuts it short. TransferText cut it short too. Someone
suggested that I use the following code. It works, but it
populates only one row of the text. Missing something critical.

Any ideas on how to get this to work?

'Beginning of code ***************
Public Function PopText()
Dim rst1 As ADODB.Recordset
Dim longStr As String
Dim f1 As Long
Set rst1 = New ADODB.Recordset
rst1.Open "TFERraw", CurrentProject.Connection, adOpenKeyset,
adLockOptimistic

Open "C:\Documents and Settings\Bob\Desktop\TFER2\TFER1.txt" For
Input As #1

Do While Not EOF(1)
rst1.AddNew
f1 = LOF(1)
longStr = Input(f1, #1)
rst1("Text1") = longStr
rst1.Update
Loop

Close #1
rst1.Close
Set rst1 = Nothing
End Function
'End of code***************


I regularly read in whole documents into memo fields with no
problems... I read line by line.

myFile = "c:\windows\temp\zzJMM.htm"
Open myFile For Input As #1
Do While Not EOF(1)
Line Input #1, myLine
If Len(myHTML) > 0 And Len(myLine) > 0 Then myHTML = myHTML &
Chr(13) & Chr(10) 'insert line feed
myHTML = myHTML & myLine
Loop
Close #1
Me![ArticleHTML] = myHTML


--
regards,

Bradley
Nov 12 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.