Authors and creating documents-querysave

Does anyone have any ideas on this-

This is my code in the querysave event of my form.

Sub Querysave(Source As Notesuidocument, Continue As Variant)

Dim fSession As New notessession

Dim sSession As NotesSession

Dim sdb As NotesDatabase

Dim fwsWorkspace As New Notesuiworkspace

Dim fdbCurrent As notesdatabase

Dim fdocCounter As notesdocument

Dim fdocCurrent As notesuidocument

Dim fview As NotesView

Dim arrvalues As Variant

Dim arrvalues1 As Variant



Set fdbCurrent = fSession.CurrentDatabase

Set fdocCurrent = fwsWorkspace.CurrentDocument



Set sSession = New NotesSession

Set sdb = sSession.CurrentDatabase



'If finding number field = blank then search through finding counter_

'view comparing finding report number to RNumber (header report #)_

'if match use value in finding counter as finding #

If (fdocCurrent.FieldGetText("FNumber") = "") Then

	Set fview = sdb.GetView("FID")

	Set fdocCounter =fview.GetFirstDocument

	While Not (fdocCounter Is Nothing) 	

		arrvalues = fdocCounter.GetItemValue("FdingRptNumber")

		If (arrvalues(0) = fdocCurrent.FieldGetText("ReportNumber")) Then

			arrvalues = fdocCounter.GetItemValue("FdingCounter")

			If Cstr(Cint(arrvalues(0))) =< 9 Then

				arrvalues1 = "0" & Cstr(Cint(arrvalues(0)))

				Call fdocCurrent.FieldSetText("FNumber",arrvalues1)

			Else

				Call fdocCurrent.FieldSetText("FNumber",arrvalues(0))

			End If

			fdocCounter.F_Author_Auditor = "[Auditor]"

			fdocCounter.FdingCounter = Cstr(Cint(arrvalues(0)) +1)

			Call fdocCounter.Save(False,False)

		End If

		Set fdocCounter = fview.getnextdocument(fdocCounter)

	Wend

	'If no match set finding number to 1 and create new counter document_

'using ReportNumber and FdingCounter

	If (fdocCurrent.FieldGetText("FNumber") = "") Then

		Call fdocCurrent.FieldSetText("FNumber", "01")

		Set fdocNewCounter = New NotesDocument(fdbCurrent)	

		fdocNewCounter.form = "FdingCounter"

		fdocNewCounter.FdingRptNumber = fdocCurrent.fieldgetText("ReportNumber")

		fdocNewCounter.FdingCounter = "2"

		fdocNewCounter.F_Author_Auditor = "[Auditor]"

		Call fdocNewCounter.Save(False,False)

		

	End If

	

	

End If

Msgbox "Report" & " " & fdocCurrent.FieldGetText("ReportNumber") & "  was saved with the Finding Number of " & fdocCurrent.FieldgetText("FNumber")

End Sub

When there is not a match the code works fine. But when there is a match between the counter report number and the current doc report number I receive a message Notes Error you cannot update or delete the document because you are not listed as a valid author when it get to the line of code Call fdocCounter.Save(False,False) I thought if I added an author field to the form that would work but I am still getting the same message.Any ideas would be helpful.

thanks

Sue

Subject: Authors and creating documents-querysave

You don’t actually add an authorsfield.

If you want the field F_Author_Auditor is an Authorsfield, you must create it like this:

set tmpitem = new notesitem(fdocNewCounter,“F_Author_Auditor”,“[Auditor]”, AUTHORS)

cheers,

Tom

Subject: RE: Authors and creating documents-querysave

Thanks Tom. I believe I got it working.