|
-
Jul 15th, 2004, 04:22 AM
#1
Thread Starter
Junior Member
Weird replace error (SOLVED)
I have a Access database with field type=Memo.
When I show this field in the browser I use this:
<%
descr = rsVisitReport("Address")
descr = replace(descr, vbCrlf, "<BR>")
Response.Write descr
%>
This works fine with fields that contain data but it returns an error when the Address field is empty.
Microsoft VBScript runtime error '800a005e'
Invalid use of Null: 'replace'
/system/Page.asp, line (number)
So I tried this little code:
<%
if (not rsVisitReport("Address")="") then
descr = rsVisitReport("Address")
descr = replace(descr, vbCrlf, "<BR>")
Response.Write descr
end if
%>
This fixes the old problem and empty fileds are shown correctly but when the field isn't empty and the replace takes place, now give the error:
Microsoft VBScript runtime error '800a005e'
Invalid use of Null: 'replace'
/system/Page.asp, line (number)
I don't get it.
Last edited by ShotokanTuning; Jul 15th, 2004 at 04:47 AM.
-
Jul 15th, 2004, 04:29 AM
#2
Nulls - always crap.
Couple of ways to fix:
1) strData = rst("field") & ""
2) strData = nnz(rst("field"),"") - where nnz is a function to replace the nnull value with a default value
3) If not (Isnull(rst("field"))) then 'do code to process/replace
Vince
Feeling like a fly on the inside of a closed window (Thunk!)
If I post a lot, it is because I am bored at work! ;D Or stuck...
* Anything I post can be only my opinion. Advice etc is up to you to persue...
-
Jul 15th, 2004, 04:45 AM
#3
Thread Starter
Junior Member
Method 3 is the same as I used. Also same result.
Method 1 works perfectly.
Thanks again.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|