?
Solved

Limit string length from Access

Posted on 2000-04-02
10
Medium Priority
?
293 Views
Last Modified: 2010-05-02
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
Comment
Question by:russoffl
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 7
  • 2
10 Comments
 
LVL 14

Accepted Solution

by:
wsh2 earned 24 total points
ID: 2678912

strWebField = Left(rs!YourFieldName, 80)
0
 
LVL 14

Expert Comment

by:wsh2
ID: 2678915
rs being your Recordset name.. <smile>.
0
 
LVL 1

Author Comment

by:russoffl
ID: 2678926
That's what I figured but then I thought that would only return character # 80.

Thanks
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 14

Expert Comment

by:wsh2
ID: 2678927
Or if you are using SQL statements

SELECT SUBSTRING(myField, 1, 80) FROM MyTable
0
 
LVL 6

Expert Comment

by:setiawan
ID: 2678939
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
 
LVL 14

Expert Comment

by:wsh2
ID: 2678958
To just get character #80.. you would use the following statement..

strChar80 = Mid(MyVariable, 80, 1)
0
 
LVL 14

Expert Comment

by:wsh2
ID: 2678961
Oh.. and Setiawan try this declaration sometime..

Dim MyString as String * 80

MyString will always be 80 characters long.. <smile>.
0
 
LVL 1

Author Comment

by:russoffl
ID: 2678962
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
 
LVL 14

Expert Comment

by:wsh2
ID: 2678981
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
 
LVL 14

Expert Comment

by:wsh2
ID: 2678982
Ooops.. and or do what you do.. setup multiple text fields.. <smile>.
0

Featured Post

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.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month14 days, 20 hours left to enroll

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question