You might want to consider doing it outside of SQL just for the simple fact the 50th position might be in the middle of a word, and I'd think you'd want to show the whole word.
Something like this should work OK (warning not tested for ffs(fat finger syndrome)):
Code:
Function Get50(FieldIn)
If mid(FieldIn, 50, 1) = " " then
Get50 = Left(FieldIn, 50)
ElseIf
HoldLength = instr(FieldIn, ",", 51)
If HoldLength = 0 then HoldLength = instrev(FieldIn, ",", 50) ' in case no spaces are after 50
if HoldLength = 0 then
' no spaces found at all (doubtful but could happen), so take first 50 characters
Get50 = Left(FieldIn, ",", 50)
else
' take length based on the appropriate space.
Get50 = Left(FieldIn, HoldLength)
end if
End Function
Bookmarks