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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how can i split a section of text into multiple fields 2

Status
Not open for further replies.

overdraft015

Programmer
Nov 25, 2007
123
GB
(sorry the subject wasnt descriptive enough)

i have a field which can be up to 50chars long. it is a description of products. i build a table to show the product and description (in seperate fields) but i need to be able to split the description into multiple fields because the char size is to big for what im doing.

e.g.

Product Desc1(10chars) Desc2(10chars) Desc3(10chars)

1234 Super Size Cup 100 c l (white)


i can do this using the Mid$() function but i dont want to split a word into two fields. how can intelligently make it so that it either puts the word that would b split into the next field to ensure the full word stays whole?

hope i made it clear enough and hope someone can held. i was thinking maybe ill have to loop or something but cant get my head around it.
 
Replace this:
For i = 0 To UBound(astrText)
If UBound(astrText) > 2 Then
MsgBox "This won't fit, too many parts."
End If
strsql = "SELECT Product, desc1, desc2, desc3 FROM [New Prod] " _
& "WHERE product='" & rs.Fields(1) & "'"
Set rs2 = db.OpenRecordset(strsql)
rs2.Edit
rs2!Desc1 = astrText(0)
rs2!Desc2 = astrText(1)
rs2!Desc3 = astrText(2)
rs2.Update
Next
With this:
If UBound(astrText) > 2 Then
MsgBox "This won't fit, too many parts."
End If
strsql = "SELECT Product, desc1, desc2, desc3 FROM [New Prod] " _
& "WHERE product='" & rs.Fields(1) & "'"
Set rs2 = db.OpenRecordset(strsql)
rs2.Edit
rs2!Desc1 = astrText(0)
If UBound(astrText) > 0 Then rs2!Desc2 = astrText(1)
If UBound(astrText) > 1 Then rs2!Desc3 = astrText(2)
rs2.Update

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top