Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to pass Attachments from one form to another?

Status
Not open for further replies.

amilian

MIS
Jan 10, 2001
3
US
I am trying to copy attachments from one form to another using a data input form which is not save, and all other field types I am able to pass except Rich Text. But I can not figure out the proper statement for rich text. I have tried CopyItemToDocument & CopyItem, but can not get either to work. Here is my shorten script:

Dim s As New notessession
Dim db As notesdatabase
Dim docT As notesdocument

Dim uiw As New notesuiworkspace
Dim uidoc As notesuidocument

Dim tcategory As String

Set db = s.currentdatabase
Set uidoc = uiw.currentdocument
Call uidoc.refresh


tcategory = uidoc.fieldgettext("tcategory")


Set docT = db.createdocument
With docT
.form = "todo"
.category = tcategory
 
Use this code in the Postopen event on your second form. This is assuming that the second form is a response to the first. The script coppies everythng in the Body field to the new form. You'll need to create a view to list all docs by their ID.

Sub Postopen(Source As Notesuidocument)
Dim workspace As New NotesUIWorkspace
Dim session As New NotesSession
Dim db As Notesdatabase
Dim maindoc As NotesDocument
Dim doc As NotesDocument
Dim view As notesview
Set db = session.CurrentDatabase
Set view=db.getview("DocByID")

'Current document
Set uidoc = workspace.CurrentDocument
Set doc = uidoc.document

'Parent Document
ParentID=doc.MainID(0)
Set maindoc=view.getdocumentbykey(ParentID)

If Not maindoc Is Nothing And uidoc.IsNewDoc Then
Set item = maindoc.GetFirstItem("Body")
Call item.CopyItemToDocument(doc, "Body")
End If
End Sub

Hope this helps
 
excellent tip, except i forgot to mention it is not a response doc. basically i have 1 main form which is used to created six diferent documents depending on the user input.

I tired CopyItemToDocument but could not get it to work. always got an 'object variable not set error'.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top