Value checking for rich text field

hi

i have dialog list button, where the input are computed from other form. this code refresh other field including rich text field, but the old value of rich text field(the attachment) still remain outside the table form.

how can i delete the old attachment, and just grab the new attachment???

tq

Sub Click(Source As Button)

On Error Goto ErrHandlr



Dim db As NotesDatabase 



Dim currdoc As NotesDocument

Dim lkpview As NotesView

Dim docCourse As NotesDocument

Dim cn As String

'Dim newKey As String

'Dim Att_Item As NotesRichTextItem

Dim rtitemB As NotesRichTextItem

Dim opendoc As NotesDocument



'>>>>>>>try baru

Dim ws As New NotesUIWorkspace

Dim session As New NotesSession

Dim uidoc As NotesUIDocument, uidocNew As NotesUIDocument

Dim rti As NotesRichTextItem

Dim attach_file As String



'>>>>>>>>>>>to check value in rich text field<<<<<<<



'>>>>>>>>>>>>>>>>>>>>>>>



Set uidoc = ws.CurrentDocument

uidoc.Refresh True

Set currdoc = uidoc.Document  ' get the back-end document for the document open on screen.

attach_file = uidoc.CurrentField' remember the current field if any





Set db = session.CurrentDatabase





a = Evaluate({ @DbColumn("";@DBName;"lsvCourseSession";1)}, currdoc)

cn = ws.Prompt(PROMPT_OkCancelList, "Course Name", "Select course name.", " ", Arrayunique(a) )



'If (cn="-Others-") Then

	'newKey = ws.Prompt(PROMPT_OkCancelEdit, "Course Name",  "Please enter new course name", " ")

'End If



	'>>>>> To Get Document from Course Name <<<<<	

key = cn	



Set lkpview = db.GetView("lsvCourseSession")

Set docCourse = lkpview.GetDocumentByKey(key, True)







currdoc.flagRefreshment = "Yes"



If Isempty(cn) Then

	Exit Sub

Else

	If Not (docCourse Is Nothing) Then

		

		currdoc.CourseName = docCourse.CourseName

		currdoc.TypeOfTraining = docCourse.TypeOfTraining(0)

		currdoc.AppCat = docCourse.AppCat 

		currdoc.Objectives = docCourse.Objectives	

		currdoc.CourseLocation  = docCourse.CourseLocation 

		currdoc.Facilitator = docCourse.Facilitator

		currdoc.StartDate = docCourse.StartDate

		currdoc.EndDate = docCourse.EndDate

		currdoc.Duration = docCourse.Duration

		'currdoc.SpecificTime = docCourse.SpecificTime

		currdoc.Act_CF = docCourse.Act_CF

		currdoc.Refreshment = docCourse.Refreshment	

		currdoc.nFees = docCourse.nFees

		currdoc.TotalCFees = docCourse.TotalCFees

		currdoc.Payment = docCourse.Payment

		currdoc.Payable = docCourse.Payable

		currdoc.SessionID=docCourse.SessionID

		

		

		'************* attachment section********

		Set rti = New NotesRichTextItem(currdoc,"attach_file")

		Set rti = currdoc.GetFirstItem("attach_file") ' insert your fieldname here, generally "Body"

		Set rtitemB = docCourse.GetFirstItem( "attach_file" )

		'************* attachment section********

		

		'>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>test baru

		' Make your rich text changes here, for instance:

		Call rti.AddNewLine(1, True)

		Call rti.AppendRTItem(rtitemB)

		

		

		

		If session.NotesBuildVersion >= 190 Then

			rti.Update ' ND6 and later

		Else

			Call currdoc.ComputeWithForm(True, False) ' caution, as this may erase some field values if you have @Db functions in formulas.

		End If

		

		currdoc.SaveOptions = "0" ' make it possible to close the document without a "do you want to save" prompt. If this is a mail-in doc you may need to set MailOptions="0" also to avoid being prompted.

		Call uidoc.Close(True)

		Set uidocNew = ws.EditDocument(True, currdoc, , , , True)

		Delete uidoc

		uidocNew.Document.RemoveItem("SaveOptions")

		If attach_file <> "" Then uidocNew.GotoField(attach_file) ' return focus to field that was current before.

		

	End If

	

End If



Exit Sub

ErrHandlr :

If Err = 4411 Then Exit Sub

Msgbox "ERROR : " & Err & " - " & Error & " at line " & Cstr(Erl),16,"Select Course Name Button"

Continue = False

Exit Sub

End Sub