Solved

Limit string length from Access

Posted on 2000-04-02
10
291 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 6 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
SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

 
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

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

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

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

688 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