Validate a RichText Field

Hello Everyone, I need some help!I’ve these code and it’s an error (Object Variable Not Set) in the line that have the <<< >>>.

Thanks

Function IsRTFNull(strFieldName As String) As Integer

             	Dim WS As New NotesUIWorkspace

Dim CurrentUIDoc As NotesUIDocument

Dim CampoRT As NotesRichTextItem

Dim rtnav As NotesRichTextNavigator

Dim ArchivoCompleto As Variant

Dim rtitem As Variant



             Set CurrentUIDoc = WS.CurrentDocument



rtCount = 0

IsRTFNull = False

Set CampoRT = CurrentUIDoc.Document.GetFirstItem (strFieldName)

<<<<<<<<If (rtitem.Type = RICHTEXT) Then>>>>>>>>>

Set rtnav = CampoRT.CreateNavigator

	If rtCount = 0 Then rtCount = GetCount(RTELEM_TYPE_TEXTRUN)

	If rtCount = 0 Then rtCount = GetCount(RTELEM_TYPE_TEXTPARAGRAPH)

	If rtCount = 0 Then rtCount = GetCount(RTELEM_TYPE_FILEATTACHMENT)

	If rtCount = 0 Then rtCount = GetCount(RTELEM_TYPE_DOCLINK)

	If rtCount = 0 Then rtCount = GetCount(RTELEM_TYPE_OLE)

	If rtCount = 0 Then rtCount = GetCount(RTELEM_TYPE_SECTION)

	If rtCount = 0 Then rtCount = GetCount(RTELEM_TYPE_TABLE)

	If rtCount = 0 Then rtCount = GetCount(RTELEM_TYPE_TABLECELL)		

End If	

If rtCount = 0 Then IsRTFNull = True

End Function

Subject: Validate a RichText Field

You haven’t set rtItem yet. (Object Variable Not Set)

You Dim it but you haven’t set it as anything.

Do you mean Set CampoRT to be Set rtitem?

Jeff Dayton, PCLP, CLI

Subject: RE: Validate a RichText Field

Sorry, I put it a code that was wrong.This is the one.

Thanks again!!

Function IsRTFNull(strFieldName As String) As Integer

Dim WS As New NotesUIWorkspace

Dim CurrentUIDoc As NotesUIDocument

Dim CampoRT As NotesRichTextItem

Dim rtnav As NotesRichTextNavigator

	

Set CurrentUIDoc = WS.CurrentDocument

'Dim rtitem As Variant



rtCount = 0

IsRTFNull = False

Set CampoRT = CurrentUIDoc.Document.GetFirstItem (strFieldName)

<<<<<<<If (CampoRT.Type = RICHTEXT) Then>>>>>>>

	Set rtnav = CampoRT.CreateNavigator

	If rtCount = 0 Then rtCount = GetCount(RTELEM_TYPE_TEXTRUN)

	If rtCount = 0 Then rtCount = GetCount(RTELEM_TYPE_TEXTPARAGRAPH)

	If rtCount = 0 Then rtCount = GetCount(RTELEM_TYPE_FILEATTACHMENT)

	If rtCount = 0 Then rtCount = GetCount(RTELEM_TYPE_DOCLINK)

	If rtCount = 0 Then rtCount = GetCount(RTELEM_TYPE_OLE)

	If rtCount = 0 Then rtCount = GetCount(RTELEM_TYPE_SECTION)

	If rtCount = 0 Then rtCount = GetCount(RTELEM_TYPE_TABLE)

	If rtCount = 0 Then rtCount = GetCount(RTELEM_TYPE_TABLECELL)		

End If	

If rtCount = 0 Then IsRTFNull = True

End Function

Subject: RE: Validate a RichText Field

Most likely your CurrentUIDoc.Document does not contain the strFieldName as a NotesItem. The

Set CampoRT = CurrentUIDoc.Document.GetFirstItem (strFieldName)

must be returning nothing.

Use the debugger to step it through one line at a time to verify. If the NotesItem does not yet exist, as in a new document, you will either have to move the code to a different event (PostSave or other), or performe a ComputeWithForm, or explicitly create the NotesRichTextItem.

Subject: RE: Validate a RichText Field

Can you adjust the space before brackets in

CurrentUIDoc.Document.GetFirstItem (strFieldName)

as

CurrentUIDoc.Document.GetFirstItem(strFieldName)

and give a try again?