Subject: ReplaceItemvalue - type mismatch
It’s a simple enough script.I assume the statement Set s = NewNotesSession is a typo.
It should, of course, be Set s = New NotesSession
Could it be that the item you are trying to update - Course - is not a Text item but perhaps numeric?
I would recommend you always use an error handler, like this:
Sub Click(Source As Button)
Dim s As NotesSession
Dim db As NotesDatabase
Dim v As NotesView
Dim Doc As NotesDocument
Dim strMsg As String
On Error GoTo errHandler
Set s = NewNotesSession
Set db = s.Currentdatabase
Set v = db.getView (“student”)
Set doc = v.getDocumentByKey(“Michael”, True)
Call doc.ReplaceItemvalue(“Course”, “Advanced”)
Call doc.Save (False,True)
bailOut:
Exit Sub
errHandler:
strMsg = “Error in the code.” & chr(10)
strMsg = strMsg & "Error code: " & Cstr(Err()) & chr(10)
strMsg = strMsg & "Error text: " & Error$ & chr(10)
strMsg = strMsg & "Error line: " & Cstr(Erl())
MessageBox strMsg, 16, “Error”
Resume bailOut
End Sub
Notice that I added the ‘True’ argument to the view lookup.
You need that to make sure you get a unique document.
Hope this helps.
// Ken Haggman, http://www.NotesHound.com