473,325 Members | 2,774 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,325 software developers and data experts.

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

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
4 1941
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Nashat Wanly | last post by:
HOW TO: Call a Parameterized Stored Procedure by Using ADO.NET and Visual C# .NET View products that this article applies to. This article was previously published under Q310070 For a Microsoft...
121
by: typingcat | last post by:
First of all, I'm an Asian and I need to input Japanese, Korean and so on. I've tried many PHP IDEs today, but almost non of them supported Unicode (UTF-8) file. I've found that the only Unicode...
11
by: Grasshopper | last post by:
Hi, I am automating Access reports to PDF using PDF Writer 6.0. I've created a DTS package to run the reports and schedule a job to run this DTS package. If I PC Anywhere into the server on...
0
by: Lokkju | last post by:
I am pretty much lost here - I am trying to create a managed c++ wrapper for this dll, so that I can use it from c#/vb.net, however, it does not conform to any standard style of coding I have seen....
1
by: ratnakarp | last post by:
Hi, I have a search text box. The user enters the value in the text box and click on enter button. In code behind on button click i'm writing the code to get the values from the database and...
18
by: Jen | last post by:
I'm using Microsoft's own VB.NET FTP Example: http://support.microsoft.com/default.aspx?scid=kb;en-us;832679 I can get the program to create directories, change directories, etc., but I can't...
1
by: kingster | last post by:
Hi, I have a regular dataset and all i want to do is make a pivot table display in a browser with the datasource of the pivot table to be this dataset and then the end-user will be able to do...
53
by: Hexman | last post by:
Hello All, I'd like your comments on the code below. The sub does exactly what I want it to do but I don't feel that it is solid as all. It seems like I'm using some VB6 code, .Net2003 code,...
21
KevinADC
by: KevinADC | last post by:
Note: You may skip to the end of the article if all you want is the perl code. Introduction Uploading files from a local computer to a remote web server has many useful purposes, the most...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.