Why Type mismatch? in my LS

I get Type mismatch when the script reach txtEvaluate, anyone who now why?I’m looking in a field (ActiveInThisDB) after the username, if the username is there a will remove it.


Sub Queryclose(Source As Notesuidatabase, Continue As Variant)

Dim wks As New NotesUiWorkspace

Dim session As New NotesSession

Dim db As NotesDatabase

Dim SearchView As NotesView

Dim activeDoc As NotesDocument

Dim docColl As NotesDocumentCollection

Dim item As notesitem

Dim result As Variant

Dim test As String

Set db = session.CurrentDatabase

Set SearchView = db.GetView( “(CheckActiveUser)” )

Call SearchView.Refresh

Set docColl = searchview.GetAllDocumentsByKey(“Active”)

If docColl.Count > 0 Then

Set activeDoc = docColl.GetFirstDocument

While Not activeDoc Is Nothing

userName = session.UserName

Set item = activeDoc.GetFirstItem(“ActiveInThisDB”)

'############################################################################################################

txtEvaluate = |@Trim(@Replace(| & item.values & |;| & userName & |;| & “”“” & |))|

'############################################################################################################

result = Evaluate(txtEvaluate, activeDoc)

activeDoc.ActiveInThisDB = result

Call activeDoc.Save(True,False)

Set activeDoc = docColl.GetNextDocument(activeDoc)

Wend

End If

End Sub


Kind regards

Fredrik

Subject: Why Type mismatch? in my LS

I think the problem is due to the 4 double quotation marks. Can you try this statement instead…txtEvaluate = |@Trim(@Replace(| & item.values & |;| & userName & |;“”))|

Regards

Zaheed

Subject: RE: Why Type mismatch? in my LS

Thanx for your help but a still get Type mismatch?

Subject: Why Type mismatch? in my LS

*********txtEvaluate = |@Trim(@Replace(| & item.values & |;| & userName & |;| & “”“” & |))|


You are trying to concatenate item.values to a string. Problem here is that unless it is a RichTextItem, you will receive a array instead of a single value.

I would venture a educated guess that your script will compile because there is a chance that they are NOT arrays, but at runtime they ARE arrays, causing a Type Mismatch.

Try using item.values(0) if there is only one

value that you need, or process the values into a single string before Evaluate

Subject: Why Type mismatch? in my LS

This is the solution, after this a will hate Evaluaton.

Sub Queryclose(Source As Notesuidatabase, Continue As Variant)

Dim wks As New NotesUiWorkspace

Dim session As New NotesSession

Dim db As NotesDatabase

Dim SearchView As NotesView

Dim activeDoc As NotesDocument

Dim docColl As NotesDocumentCollection

Dim item As notesitem

Dim result As Variant

Dim txtEvaluate As String



Set db = session.CurrentDatabase

Set SearchView = db.GetView( "(CheckActiveUser)" )

Call SearchView.Refresh

Set docColl = searchview.GetAllDocumentsByKey("Active")

If docColl.Count > 0 Then

	Set activeDoc = docColl.GetFirstDocument

	While Not activeDoc Is Nothing

		userName = session.UserName

		txtEvaluate = |@Trim(@Replace(ActiveInThisDB;"| & userName & |";""))|

		result =  Evaluate(txtEvaluate, activeDoc)

		

		activeDoc.ActiveInThisDB = result

		Call activeDoc.Save(True,False)

		Set activeDoc = docColl.GetNextDocument(activeDoc)

	Wend

End If

End Sub

Thanx all for your help

Fredrik

Subject: Why Type mismatch? in my LS

Since you are using R6, no need to use the Evaluate statement to replace a value.

try,

activeDoc.ActiveInThisDB = Replace(activeDoc.GetFirstItem(“ActiveInThisDB”).Values,username,“”)

cheers !!

Ashish