Transferring values from a field to another field in different DB

Hi everyone out there.This thing had been bugging and bothering me too long. I really need help. I have used the codes that i find online. The codes are:Sub Click(Source As Button)

Dim nsCurrent As New NotesSession

Dim ndbSource As NotesDatabase

Dim  ndbTarget As NotesDatabase 

Dim nvwTarget As NotesView

Dim ndocSource As NotesDocument

Dim ndocTarget As NotesDocument



Set ndbSource = nsCurrent.CurrentDatabase 

Set ndbTarget = nsCurrent.getDatabase(ndbSource.Server  , "PRreq.nsf")

Set nvwTarget = ndbTarget.getView("FN")

Set ndocTarget = nvwTarget.getDocumentByKey("PR",True)

If Not ndocTarget Is Nothing Then

	ndocTarget.Brand1=ndocSource.brand

Else

	Msgbox "Could not access target document", 16, "Error"

	

End If

End Sub.

But when it reach the line that says; “Set nvwTarget = ndbTarget.getView(“FN”)” It gives the error that says Database – ----- PReq.nsf has not been opened yet. I have another different codes in which i tried, but it was too long and too confusing.

Can some one help me pls. Can anybody SUGGEST any other way on doing/ any sample codes. I would like to transfer a value in the field to another field in different database.When i press the action button, i want the computed fields in the target form to appear with the values.(Scripts are done in the “click” button)

Any Respond will be much appreciated. God Bless.

Subject: Transferring values from a field to another field in different DB

You pasted this in as a “Click” script. Is it really a button, or is this code in a server agent?

As regards the message “database has not been opened yet”, please see this thread: http://www-10.lotus.com/ldd/nd6forum.nsf/0/1d342e7d41338a4a85256e71002c50b5?OpenDocument

I think the problem is most likely that either is no such database, or you have no access to it. Probably you do have access to it, and you have just failed to provide the complete filepath (e.g. it’s really “prapps\prreq.nsf”). Filepaths on UNIX (and related OS) are case sensitive.

A couple of other problems I see, which you will run into after you solve this one. This line:

Set ndocTarget = nvwTarget.getDocumentByKey("PR",True)

searches for the document whose key value is the literal string “PR”. I think you probably meant to search for the document whose key is the same as the PR field from the current document:

Dim wksp As New NotesUIWorkspace

Dim uidoc As NotesUIDocument

Dim doc As NotesDocument

Set uidoc = wksp.CurrentDocument

Set doc = uidoc.Document

Set ndocTarget = nvwTarget.getDocumentByKey(doc.PR(0), True)

Also, it does no good to change a field in the target document unless you also save changes. E.g.:

ndocTarget.Brand1=ndocSource.brand

Call ndocTarget.Save(True, True, True)

Subject: RE: Transferring values from a field to another field in different DB

Hi Andre, thanks for replying. This is a button. I put the code in the button (click script). Well, 1 thing that i forgot to explain is : when i click this button, i would like the computed fields (the targeted forms appear and the fields were filled with values from fields from the 1st forms.)Btw, i’ve already open the link, but for my case, there shouldn’t have anything to do with agent right?

Thanks once again.