Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

record is too large

Status
Not open for further replies.

shanmugham

Programmer
Jun 19, 2001
71
IN
Dear Sirs,

i have the following code

str1 = LTrim(RTrim(str1))


for i = 1 to 100

Select Case ctr
Case 1
rs("line1") = str1
Case 2
rs("line2") = str1
Case 3
rs("line3") = str1
Case 4
rs("line4") = str1
Case 5
rs("line5") = str1
Case 6
rs("line6") = str1
Case 7
rs("line7") = str1
Case 8
rs("line8") = str1
Case 9
rs("line9") = str1
Case 10
rs("line10") = str1
Case 11
rs("line11") = Mid$(str1, 1, Len(str1))
Case 12
rs("line12") = str1
Case 13
rs("line13") = str1
Case 14
rs("line14") = str1
Case 15
rs("line15") = str1
Case 16
rs("line16") = str1
Case 17
rs("line17") = str1
Case 18
rs("line18") = str1
Case 19
rs("line19") = str1
Case 20
rs("line20") = str1
Case 21
rs("line21") = Mid$(str1, 1, Len(str1))
Case 22
rs("line22") = str1
Case 23
rs("line23") = str1
Case 24
rs("line24") = str1
Case 25
rs("line25") = str1
Case 26
rs("line26") = str1
Case 27
rs("line27") = str1
Case 28
rs("line28") = str1
Case 29
rs("line29") = str1
Case 30
rs("line30") = str1
Case 31
rs("line31") = Mid$(str1, 1, Len(str1))
Case 32
rs("line32") = str1
Case 33
rs("line33") = str1
Case 34
rs("line34") = str1
Case 35
rs("line35") = str1
Case 36
rs("line36") = str1
Case 37
rs("line37") = str1
Case 38
rs("line38") = str1
Case 39
rs("line39") = str1
Case 40
rs("line40") = str1
Case 41
rs("line41") = Mid$(str1, 1, Len(str1))
Case 42
rs("line42") = str1
Case 43
rs("line43") = str1
Case 44
rs("line44") = str1
Case 45
rs("line45") = str1
Case 46
rs("line46") = str1
Case 47
rs("line47") = str1
Case 48
rs("line48") = str1
Case 49
rs("line49") = str1
Case 50
rs("line50") = str1
End Select
next i

rs.Update


each time str1 has different texts ..

above is the sample code

kindly give me a simplest code

i am using vb6 and access 97

each str having the 100 characters long.

at the running time, it gives the message "RECORD IS TOO LARGE "

how to update this

thanks in advance


shanmugham
 
What are you trying to do?
what is rs("Line1")? Is it a variable or a record in a data base?
 
the reason it it so large is that str1 which is a 100 digits long will be written into a particular line 101 times because ctr never changes and it is on a loop.
 
There are a few problems with your code.

First:

Code:
str1

and

Code:
Mid$(str1, 1, Len(str1))

will both produce the same string.

Second:

All this loop is doing is re-assigning str1 to rs("line##") 100 times. Inside the loop, the value of
Code:
ctr
, as well as the value of
Code:
str1
, needs to be changing.

As ICISYD stated, str1 will be written to a particular line 100 (not 101) times, but each time it will overwrite what was already there, so this should not affect the size of the record.

Third:

Code:
str1 = LTrim(RTrim(str1))

could more easily be written

Code:
str1 = Trim(str1)

Fourth:

If rs("line##") is referring to a field in a record, and there actual names are line1, line2, etc., you do not need the Select Case statement. In the Select Case statement, the line number always corresponds to the value of
Code:
ctr
, so that when
Code:
ctr = 1
, the line number is one; when
Code:
ctr = 2
, the line number is 2. You can simply say:

rs("line" & ctr) = str1

If the fields are not named as such, you could reference the field number, and have the field number correspond to the value of
Code:
ctr
.

But you still have to change the value of str1 and ctr somewhere in the loop. And, since your loop executes 100 times, and there are only 50 fields, something is still going to be overwritten.

As for the "Record Is Too Large" error, could it be that the field length in the database is set to be smaller than then length of str1?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top