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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error Message:Function requires a valid ADT Argument

Status
Not open for further replies.

gem28

Instructor
Nov 5, 2001
64
PH
Hi!
I'm trying to copy all the items in a document as I click the edit button. My fields are a combination of text and richtext fields. When I run this, I get an error message: "Function requires a valid ADT Argument".
I'm not sure what it means and I'm not sure if I can use "CopyAllItem" function so I don't have to identify each item in the form when I copy.

By the way, I intend to copy the items into another document of another dbase which I placed on my local.

Below is the procedure i tried for this:

Sub StatusApp(ws As notesuiworkspace, uidoc As notesuidocument, doc As notesdocument)
Dim docritem As NotesItem
Dim session As New notessession
Dim db As notesdatabase
Dim dbArchive As notesdatabase
Dim relate As NotesRichTextItem
Dim purpose As NotesRichTextItem
Dim outputs As NotesRichTextItem
Dim educ As NotesRichTextItem
Dim skill As NotesRichTextItem

Set db = session.currentdatabase

form = doc.Form(0)

If form = "JD" Then
key = doc.pagekey(0)
status = doc.STATUS(0)
title = doc.Title(0)
dept = doc.DEPARTMENT_1(0)
div = doc.DIVISION(0)
num = doc.NUMBER(0)
category = doc.CATEGORY(0)
location = doc.LOCATION(0)
level = doc.LEVEL(0)
update = doc.REVIEW_DATE(0)
dformat = doc.dformat(0)
Set relate = New NotesRichTextItem ( doc, "REP_RELATION" )
Set purpose = New NotesRichTextItem ( doc, "PURPOSE" )
Set outputs = New NotesRichTextItem ( doc, "OUTPUTS" )
ccs = doc.CORE_COMP_AS(0)
ccn = doc.CORE_COMP_NO(0)
ks = doc.KR_SUP(0)
ki = doc.KR_IC(0)
ke = doc.KR_EC(0)
kds = doc.KR_DUTIES_SUP(0)
kdi = doc.KR_DUTIES_IC(0)
kde = doc.KR_DUTIES_EC(0)
Set educ = New NotesRichTextItem ( doc, "EDUC" )
Set skill = New NotesRichTextItem ( doc, "SKILL" )
num1 = doc.NUM_1(0)
update = doc.UPDATED(0)
Set docritem = doc.GetFirstItem("Content")
Call uidoc.Close

Set dbArchive = session.GetDatabase ("","vacmonArchive.nsf")
Set newdoc = dbArchive.createdocument()
newdoc.form = "JobDesc_New"
newdoc.status = "Draft"
newdoc.pagekey = key
newdoc.Title = title
newdoc.DEPARTMENT_1 = dept
newdoc.DIVISION = div
newdoc.NUMBER = num
newdoc.CATEGORY = category
newdoc.LOCATION = location
newdoc.LEVEL = level
newdoc.REVIEW_DATE = update
newdoc.dformat = dformat
Set relate = New NotesRichTextItem ( newdoc, "REP_RELATION" )
Set purpose = New NotesRichTextItem ( newdoc, "PURPOSE" )
Set outputs = New NotesRichTextItem ( newdoc, "OUTPUTS" )
newdoc.CORE_COMP_AS = ccs
newdoc.CORE_COMP_NO = ccn
newdoc.KR_SUP = ks
newdoc.KR_IC = ki
newdoc.KR_EC = ke
newdoc.KR_DUTIES_SUP = kds
newdoc.KR_DUTIES_IC = kdi
newdoc.KR_DUTIES_EC = kde
Set educ = New NotesRichTextItem ( newdoc, "EDUC" )
Set skill = New NotesRichTextItem ( newdoc, "SKILL" )
newdoc.NUM_1 = num1
newdoc.UPDATED = update
Call newdoc.CopyItem(docritem,"Content")
Messagebox "Document Saved"
Set uidoc = ws.Editdocument(True,newdoc)
Call uidoc.GotoField("Content")
End If
End Sub

.. So sorry for the long code, but any help is truly, truly, appreciated! :D

best regards,
tin
 
When you Google for the error message, you happen upon a useful link in the first few listed.

It indicates that your document object is deallocated before you use it.

I think your problem lies in the following :

1) you allocate a docritem object that belongs to the doc object, which is dependant on the uidoc object.
2) you deallocate the ui document object (uidoc.close deallocates it), thereby deallocating the doc object and all associated objects.
3) you create a new document object and use docritem to set a value, but docritem has been deallocated along with doc and uidoc.

If this is indeed the root of the issue, I would advocate the following :

1) allocate a temporary document object, I'll call it tempdoc.
2) copy the docritem object to tempdoc.
3) close the ui document.
4) create the new document and use the docritem as intended from the tempdoc object.

Pascal.


I've got nothing to hide, and I'd very much like to keep that away from prying eyes.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top