Creating a document with multiple Call Statements

15 pts.
Tags:
Domino Designer
LotusScript
I'm trying to combine these to Subroutines Dept50 and Dept56 which loops theough arrays and retrieves sql tags. Eveytime I run my agent it create 2 documents where only one is needed. This is in the Sub Initialize Call Dept50 success = detdoc.Computewithform(True, True) Call Dept56 success = detdoc.Computewithform(True, True) Call detdoc.save(True,True) Msgbox "Document Created" 'If Date <> "" Then 'Call Dept50 'Call Dept56 'Set DetDoc = New notesdocument(db) 'Detdoc.form = "Details" 'success = detdoc.Computewithform(True, True) 'Call detdoc.save(True,True) 'Msgbox "Document Created" 'End If 'If Date <> "" Then 'Set DetDoc = New notesdocument(db) 'Detdoc.form = "Details" 'success = detdoc.Computewithform(True, True) 'Call detdoc.save(True,True) 'Msgbox "Document Created" 'End If

Answer Wiki

Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Discuss This Question: 5  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • Brooklynegg
    There myust be a save either in the Dept50 or Dept56 sub. Check those subs, or upload them for others to inspect.
    3,845 pointsBadges:
    report
  • Lisvard
    Each Sub is refering to a BuildDetailDoc which generates the data to the doc and I have had the save optio there, but I always end up with 2 documents. Sub Dept50 '=============================== ' Dim DetDoc As NotesDocument 'Set DetDoc = New notesdocument(db) 'Detdoc.form = "Details" '=============================== Dim session As New notessession Dim con As New ODBCConnection Dim qry As New ODBCQuery Dim result As New ODBCResultSet Dim comptag As String Dim comptime As String Dim compvalue As String Dim compstatus As String Set db = session.currentdatabase Set qry.Connection = con 'build a list of all the tags to gather BuildTagArray BegDateTime = Format(Datenumber ( Year(Today) , Month(Today) , Day(Today) ) , "dd-mmm-yy") + " 0:00" EndDateTime = Format(Datenumber ( Year(Today) , Month(Today) , Day(Today) ) , "dd-mmm-yy") + " 0:59" 'connect to PI and pass username flag = con.ConnectTo("Server1", "password") If con.GetError <> DBstsSUCCESS Then Messagebox con.GetExtendedErrorMessage,, con.GetError & " " & con.GetErrorMessage Exit Sub End If 'loop through all the tags and get the data from PI - should be one entry returned for each tag For xx = 0 To 2 qry.SQL = | SELECT tag, time, status, value FROM picomp WHERE tag = '| + TagArray(xx,0) + |' AND time >= DATE('| + _ BegDateTime + |') AND time <= DATE('| + EndDateTime + |') | Set result.Query = qry If qry.GetError <> DBstsSUCCESS Then Messagebox qry.GetExtendedErrorMessage,, qry.GetError & " " & qry.GetErrorMessage con.Disconnect Exit Sub End If result.Execute If result.GetError <> DBstsSUCCESS Then Messagebox result.GetExtendedErrorMessage,, result.GetError & " " & result.GetErrorMessage con.Disconnect Exit Sub End If If result.IsResultSetAvailable Then Do result.NextRow comptag = result.GetValue ( "TAG" ) comptime = result.GetValue( "TIME" ) compvalue = result.GetValue( "VALUE" ) If comptag <> "" Then If compvalue = 0 Then compvalue = "N/A" Else compvalue = compvalue End If TagArray(xx,1) = compvalue Else TagArray(xx,1) = Round(Cdbl(compvalue),2) End If Loop Until result.IsEndOfData result.Close(DB_CLOSE) Else Messagebox "No result for " + TagArray(xx,0) + " from 1122." End If Next xx con.Disconnect 'go get the tags and associate them with the fields on the doc, and build the doc BuildDetailDoc End Sub
    15 pointsBadges:
    report
  • Brooklynegg
    If you step through it one line at a time, or with breaks at appropriate places, I have to think you would find the second save. Let me know what you've done with the LotusScript debugger so far.
    3,845 pointsBadges:
    report
  • AGuirard
    You say each subroutine calls BuildDetailDoc. BuildDetailDoc must be where the Notes document gets created. You call BuildDetailDoc twice in all. Why are you surprised that it creates two documents? It creates one the first time you call it, and another one the next time you call it. It's rather pointless to ask us why code is behaving in a way you don't understand, if you don't show the code. You are making some assumption that you're not stating. Perhaps you're assuming that if you create new NotesDocuments with some of the same field values, then they will be magically combined in some way. Nay, nay. There's no requirement that any field in a Notes document have a unique value. If your code says to create a document, it creates a document. If it contains exactly the same field values as an existing document, so be it.
    520 pointsBadges:
    report
  • Brooklynegg
    Dear AGuirard: My point exactly. Lisvard: You have the attention of an extremely valuable and helpful Notes expert (AGuirard, not me). I would be sure to ask well-thought-out questions. You don't want him to think it is a waste of his time to try to help you. : - )
    3,845 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following