Solved

Limit string length from Access

Posted on 2000-04-02
10
288 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
  • 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
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
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…
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

792 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