Limit string length from Access

I have a field in an Access database that allows a field length of up to 255 characters.

I need to show that field in a web page using ASP, but since it is just a preview of the description I need to limit the output to 80 characters.

All I need is the VB command to limit the size of the string to the 80 characters.
LVL 1
russofflAsked:
Who is Participating?
 
wsh2Connect With a Mentor Commented:

strWebField = Left(rs!YourFieldName, 80)
0
 
wsh2Commented:
rs being your Recordset name.. <smile>.
0
 
russofflAuthor Commented:
That's what I figured but then I thought that would only return character # 80.

Thanks
0
Cloud Class® Course: CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

 
wsh2Commented:
Or if you are using SQL statements

SELECT SUBSTRING(myField, 1, 80) FROM MyTable
0
 
setiawanCommented:
Hi, russoff!

actually there is no vb command to limit the size of string.

left, mid, or right used for truncating the string (not limited).

If you want limited it, then you should do some validation such as :

if len(str) > 80 then
   ....
   ....
endif

 hope this helps :)

  danny


0
 
wsh2Commented:
To just get character #80.. you would use the following statement..

strChar80 = Mid(MyVariable, 80, 1)
0
 
wsh2Commented:
Oh.. and Setiawan try this declaration sometime..

Dim MyString as String * 80

MyString will always be 80 characters long.. <smile>.
0
 
russofflAuthor Commented:
Thanks.  No need to limit the size, just a need to limit the output in one page, while the full text version is found on another.

Any ideas on how to get around the Acces limit of 255 characters in a field.  For Writing I could concatenate, but how about writing?

I know I cold trim everything under 256, and everything over 255, and store them in seperate fields, but that seems messy.

I'll post a dummy question and award 20 points for a good valid answer.
0
 
wsh2Commented:
Unfortunately.. the Access Text field type is limited to 255 characters.. <groan>.  The only way around it is to use a Memo field.. but then you lose Text searching functionality.. <sigh>.
0
 
wsh2Commented:
Ooops.. and or do what you do.. setup multiple text fields.. <smile>.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.