Type Mismatch

I need to compare the value in two text fields (RS and RS1)on two different forms from two different databases. If the values don’t match, I need to place the value of RS into RS1. The field name RS could have a # from 1 to 6 depending on what is selected in another field. Now that everyone is thoroughly confused, here’s a brief part of my code:

If doc.JobNoTechDocs(0) >< “” Then

For n = 1 To Cint(doc.JobNoTechDocs(0))

Set child = view.GetChild(doc)

While Not (child Is Nothing)

  With remotedoc

   If remotedoc.RSAreaName+Cstr(n) <> child.RSAreaName(0) then

   .RSAreaName+Cstr(n) = child.RSAreaName(0)

End if

I’m taking information from many documents (one main and up to 6 response docs) into one document, but this one document has 6 tabs (if needed), for example, on tab 1, the field name is RSAreaName1, tab 2 is RSAreaName2, etc.

But I receive a type mismatch on this line:

If remotedoc.RSAreaName+Cstr(n) <> child.RSAreaName(0) then

If I take this line out, I get a type mismatch on the next line.

I think the problem is RSAreaName+Cstr(n), but I’m not sure how else to dynamically set the field name.

Any suggestions would be appreciated. I have over 100 fields to update.

Subject: Type Mismatch

You can’t refer to field names that way. It thinks you’re looking at the value of remotedoc.RSAreaName plus the value of Cstr(n). You need to use NotesItem to get and set the field if you want to use dynamic names. Use GetFirstItem to get it and ReplaceItemValue to set it.

Subject: Type Mismatch

You’ll need to do a GetItemValue on it, so declare an item, then set it, then you can use the dynamic code for that, then you’ll have the value. Hope that made sense.

Many thanks,

MaryJane Johnson.