Type Mismatch Error -- Lotus Script

I know that if I have a type mismatch that something is not declared properly. I have searched and tried changing my variables within my code and keep receiving the Type Mismatch Error. I have also just tried using the CStr to change my variable from a variant to a string. Error still occurs.

The error occurs on the line indicated. What I am trying to do is to create a list of files in a specific directory with the last folder indicated by combining two fields from a form in the view.

Dim session As New NotesSession

Dim db As NotesDatabase

Dim view As NotesView

Dim doc As NotesDocument

Dim pre As Variant, ECR As Variant

Dim ECO As Variant



Dim pathName As String, fileName As String



Set session = New NotesSession	

Set db = session.CurrentDatabase

Set view = db.GetView( "Admin Assis" )

Set doc = view.GetFirstDocument





pre = doc.Prefix

ECR = doc.ECRNum

ECO = Cstr(pre & ECR)     'Type Mismatch error occurs on this line.



pathName$ = "C:\Documents and Settings\terico\My Documents\Test\ ECO(0)\*.*"

fileName$ = Dir$(pathName$, 0) 



Do While fileName$ <> ""

	Print fileName$

	fileName$ = Dir$()

	Messagebox fileName$, MB_ICONINFORMATION, "File Directory"

Loop 

Any help is greatly appreciated…

Teri

Subject: Type Mismatch Error – Lotus Script

You’re applying the CStr after the attempted combination which is what fails…

Instead of

ECO = Cstr(pre & ECR)

Use:

ECO = Cstr(pre) & CStr(ECR)

Subject: Type Mismatch Error – Lotus Script

I think you have fallen victim to the missing (0) error. Try the following.

ECR = doc.ECRNum(0)

ECO = Cstr(pre & ECR)

–Ron

Subject: Folder is now empty – Type Mismatch Error – Lotus Script

This fixed my Type Mismatch and then after I removed the (0) that fixed my Variant Does not Contain a Container Error.

I also found that I had to move the messagebox up before the fileName$ = Dir$() statement so that it would show me all of the files.

Now it is working fine.

Thanks much Ron…

Subject: Type Mismatch Error – Lotus Script

Are the two fields multi-value fields or one value? If they’re single value, then simply use

pre = doc.prefix(0)

ecr = doc.ECRNum(0)

ECO = Cstr(pre) + Cstr(ecr) ’ only need to do the string conversion if the datatype of pre and ecr is NOT string

As it is, you are trying to do several things that are incorrect in VB syntax. pre and ecr are variants containing an array of values. You are trying to combine them as if they were strings. You need to combine the elements of the array.

Also, you should set EACH non-string to a string separately cstr(pre(0)) & cstr(ecr(0))

Just do this:

Dim db As NotesDatabase

Dim view As NotesView

Dim doc As NotesDocument

Dim pre As String

ECR As String

Dim ECO As String

Dim pathName As String, fileName As String

Set session = New NotesSession

Set db = session.CurrentDatabase

Set view = db.GetView( “Admin Assis” )

Set doc = view.GetFirstDocument

pre = doc.Prefix(0)

ECR = doc.ECRNum(0)

ECO = Cstr(pre & ECR)

pathName$ = “C:\Documents and Settings\terico\My Documents\Test\ ECO(0)*.*”

fileName$ = Dir$(pathName$, 0)

Do While fileName$ <> “”

Print fileName$

fileName$ = Dir$()

Messagebox fileName$, MB_ICONINFORMATION, “File Directory”

Loop

If you have multiple values in the field (that line up so that pre(1) = ecr(1), then you can encapsulate this all in a loop and process each as needed.