Type Missmatch

I am testing the first part of an agent and I get the error message TYPE MISMATCH???I don’t understand why

Dim s As NotesSession

Dim db As NotesDatabase

Dim dc As NotesDocumentCollection

Dim doc As NotesDocument

Dim item As NotesItem

Dim user As String

Set s = New notessession

Set db = s.CurrentDatabase

Set dc = db.UnprocessedDocuments

For x = 1 To dc.Count

Set doc = dc.GetNthDocument (x)

Set item = doc.GetItemValue(“LastName”)

Set user = item

Print user

Next

Call dc.GetNextDocument (x)

End Sub

Subject: Type Missmatch

It’s your call to dc.GetNextDocument (x). GetNextDocument expects a NotesDocument as the argument, not an integer – so you get a type mismatch.

I don’t even think you need that line at all.

Subject: Type Missmatch

Your problem is that you are setting User = item.

Item is a notesitem and user is a string. Try this instead: (Not tested)

Dim s As New NotesSession

Dim db As NotesDatabase

Dim dc As NotesDocumentCollection

Dim doc As NotesDocument

Dim item As NotesItem

Dim user As String

Set db = s.CurrentDatabase

Set dc = db.UnprocessedDocuments

For x = 1 To dc.Count

Set doc = dc.GetNthDocument (x)

user = doc.LastName(0)

Print user

Next

End Sub

Good Luck.

Mark

Subject: RE: Type Missmatch

This is still giving me a Type mismatch error

Subject: RE: Type Missmatch

Hi Justin,

I just tested the small piece of code a posted. I don’t know what you intend to use this for so I can’t help you further. I would not have written the agent as per your example (or mine for that matter) but it does work. Copy it into a new agent in your personal address book and try it. The names go by fast at the bottom of the client as you use the print statement so expand it up after the agent completes and you should see a list of last names of the selected people.

If you still have problems use the debugger and tell us what line specifically.

Cheers,

Mark

Subject: Type Missmatch

hi rose!you run the script debugger or wite a line above all like on error gotr e:

and at end write a label e and write

e:

print error & erl

this way you will get where does the error occur.

It is probably the line where you are doing

set user=item that creates error

Just replace it with

user=item

Print user

Hope it helps

Manu

Subject: Type Missmatch

Hi,

there are two errors, one in each line:

Set item = doc.GetItemValue(“LastName”)

Set user = item

Try

user=doc.GetItemValue(“LastName”)(0)

instead of the two buggy lines.

Best regards
Mario Varchmin