PDA

View Full Version : Access: restrict amount of output from a field



marconi
09-07-2006, 12:39 AM
Hi, I've just been reading this thread - 3 years later! I am trying to include your solution to restricting the amount of characters returned in a query. I use MS Access as my database and wonder if this is why I can't get the code to work? I get the following response:



# Error Type:
Microsoft VBScript compilation (0x800A03EE)
Expected ')'
/soundplay/Templates/testPage.asp, line 559, column 69
response.write(server.HTMLEncode(rsRelatedText.Fields("featureText"))
--------------------------------------------------------------------^


The code I'm using is as follows:

This is at the beginning of my .asp page - before the head section

<%
Dim rsRelatedText
Dim rsRelatedText_numRows

limit = 50

Set rsRelatedText = Server.CreateObject("ADODB.Recordset")
rsRelatedText.ActiveConnection = connSpMain
rsRelatedText.Source = "SELECT featureText FROM tblPages WHERE section = 'home' AND categoryLink <> 'index'"
rsRelatedText.CursorType = 0
rsRelatedText.CursorLocation = 2
rsRelatedText.LockType = 1
rsRelatedText.Open()

rsRelatedText_numRows = 0
%>



And then I have this in the body of the .asp page:


<%=(rsRelatedText.Fields.Item("featureText").Value)%>
<%
If Len(rsRelatedText.Fields("featureText")) > limit then
response.write(server.HTMLEncode(Left(rsRelatedText.Fields("featureText"), limit)) & "...") 'HTMLEncode to display the text as text and not HTML code
else
response.write(server.HTMLEncode(rsRelatedText.Fields("featureText"))
end if
%>


Can anyone still help with this issue?

In anticipation,

Marconi.

arnyinc
09-07-2006, 05:34 PM
As the error message indicates, you are missing an end parenthesis.