Link to home
Start Free TrialLog in
Avatar of johnhardy
johnhardyFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Invalid use of Null Replace

Hello Experts,
I have a results page where I want to display memo fields with the original formatting, (Line spacing)
The code below works OK until it comes to an empty field.
<%
'replace spaces and put breaks
strText = (rsUpdate.Fields.Item("SkillsRequired").Value)
strText = replace(strText,VbCrLf,"<br>")
response.write strText
%>

Then I get this error.
Invalid use of Null: 'Replace'
/britishconsultancy/Assign-COMPLETED/print.asp, line 755
Can anyone tell me what code to use to avoid the error please.
Thanks
John
Avatar of johnhardy
johnhardy
Flag of United Kingdom of Great Britain and Northern Ireland image

ASKER

I think I have found the answer with the following small ammendment.
I hope it helps someone else
Thanks
John

<%
'replace spaces and put breaks
strText = (rsUpdate.Fields.Item("PurposeNonProfit").Value)
strText = replace("" & strText,VbCrLf,"<br>")
response.write strText
%>
ASKER CERTIFIED SOLUTION
Avatar of Rouchie
Rouchie
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks Rochie for that information.
The code I altered above does seem to be working OK with empty fields.
Yes, I just included that little snippet for general reference if anyone else needs help.  Your method is simply forcing the NULL to be converted to text by adding a blank string to it.  I'm not too sure how reliable that would be should it need expanding further - but at least it works for you!
Thanks its away great to have the best advice
Regards
John