Run Agent in DB1 from button in DB2

I am trying to call a Java agent that is in DB1 from DB2. Notes help has shown the way to do this however I am not able to get this to work.Can someone tell me what I am doing wrong please???

'Button in DB2 that calls agent in DB1

is works until I try to link back to the doc

Dim s As New NotesSession

Dim ws As New NotesUIWorkspace



Set db = s.CurrentDatabase

Set uidoc = ws.CurrentDocument

Set doc = uidoc.Document



doc.TriggerUserName = s.UserName

Call doc.Save(True, False)

'Call agent

Set pdfDB = s.GetDatabase(db.Server, "anderson\PDF\pdfTemplate.nsf")

Set agent = pdfDB.GetAgent("createPDFMain")

If (agent.Run(doc.NoteID) = 0) Then

	Messagebox "Agent ran",, "Success"

Else

	Messagebox "Agent did not run",, "Failure"

End If

//Java code

NotesThread.sinitThread();

	   Session session = getSession();

	   AgentContext agentContext = session.getAgentContext();

	   Agent agent = agentContext.getCurrentAgent();

	   db = agentContext.getCurrentDatabase();

	   

         Database pdfDB = session.getDatabase(db.getServer(), "anderson\\PDF\\pdfTemplate.nsf");

         lnDoc = pdfDB.getDocumentByID(agent.getParameterDocID());

         

         String strGetResult0 = "";

         if(lnDoc != null)

           {

           	String strGetFormName = lnDoc.getItemValueString("Form");

           	}

It never seems to find the Doc from the NoteID