Hey Everyone…
I am trying to copy fields from a document in a view to a new document that a user would be creating by clicking a button in the view once they have selected the document. The code below is currently not working…
Sub Click(Source As Button)
Dim session As New notessession
Dim db As New notesdatabase("","Audits.nsf")
Dim view As notesview
Dim doc As notesdocument
Dim itemA As notesitem
Dim itemB As notesitem
Set view = db.getview("Code")
Set doc = View.GetFirstDocument
While Not (doc Is Nothing)
Set itemA = doc.getfirstitem("agentcode")
Set itemB = doc.getfirstitem("agentname")
Set doc2 = New notesdocument(db)
doc2.form = "AgentTracking"
Call itemA.copyitemtodocument(doc2,"agentcode")
Call itemB.copyitemtodocument(doc2, "agentname")
Call doc2.save(True, False)
’ Messagebox "Field One Value: " & doc.agentcode(0)
’ Messagebox "Field Two Value: " & doc.agentname(0)
Set doc= view.getnextdocument(doc)
Wend
End Sub
Subject: RE: Copyitem not working
Please refer to this, especially point 5.
Subject: RE: Copyitem not working
Hey Andre,
Sorry I didnt explain it good enough… I thought the code would be what I have attempted … Right? The rest of the stuff I have found on the forum hasn’t helped. That is why I am submitting my own problem… I have simply explained what I was trying to do. Could you offer some suggestions to make the post better.
thanks,
Adam
Subject: Yes, Your line “The code below is not working” does not even come close to giving
us a clue as to what is wrong. Do you get an error message, if so what was it? Does it create any docs in the other database? Do you get any results from your messageboxes? Did you run it through with the debugger on?Aside from all that, the agent does not do what you were suggesting that you wanted to do - “User selects document in view and agent makes copy in another database”. Your code goes and copies every document in the view “Code” in the database “Audits.nsf” (well at least 2 fields from them) to the same database.
Subject: And which part did not work? What are the symptoms?