• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 299
  • Last Modified:

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.
0
russoffl
Asked:
russoffl
  • 7
  • 2
1 Solution
 
wsh2Commented:

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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 7
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now