When my agent runs it does everything but show the messagebox for the error

15 pts.
Tags:
Lotus Agents
LotusScript
MessageBox
I wrote an agent that checks a collection and get information from different fields and should show an error message and clear fields if certain requirements are not met. The agent does everything but show the message box. Code Below.... Sub Initialize Dim ses As New NotesSession, curDb As NotesDatabase, View As NotesView, View9 As NotesView, View9byID As NotesView, viewByID As NotesView Set curDb = ses.currentDatabase Set View = curDb.getView("(63-8)") 'by pat id and date Set View9=curDb.GetView("(63-0 &63-9)") ' by pat id and date Set viewByID = curDb.GetView("(63-8 by id)") 'by pat id Set view9ByID = curDb.GetView("(63-0 &63-9 by id)") 'by pat id Dim ws As New NotesUIWorkspace Dim uidoc As NotesUIDocument Set uidoc = ws.currentdocument Dim doc As NotesDocument If uidoc.FieldGetText("ServiceArea") = "" Or uidoc.FieldGetText("TypeActivity") = "" Then Exit Sub End If strID = uidoc.FieldGetText("PatientID2TextDate") 'pat id and date strID2= uidoc.FieldGetText("PatientID2") 'pat id strDate = uidoc.FieldGetText("Date") strDate1 = uidoc.FieldGetText("Date") ' SSR date Dim keyValue As String Dim keyValue2 As String keyValue = strID keyValue2 = strID2 Dim collection As NotesDocumentCollection Dim ArchiveServer As String ArchiveServer = "ARC01/ADPH" Const ArchiveFilename = "CCArchive\ssrArchive.nsf" Dim ArchiveDb As New NotesDatabase(ArchiveServer, ArchiveFilename) Dim ArchView As NotesView Set ArchView = ArchiveDb.GetView("(63-8)") Dim ActivityCode As String Dim ServiceArea As String ActivityCode =uidoc.FieldGetText("ServiceAreaActivityType") Dim coll As NotesDocumentCollection 'get 63-8 by pat id and date Dim coll9 As NotesDocumentCollection 'get 63-9/0 by pat id and date Dim collByID As NotesDocumentCollection 'get 63-8 by pat id and date Dim coll9ByID As NotesDocumentCollection 'get 63-9/0 by pat id Dim ArchColl As NotesDocumentCollection Set Archcoll= Archview.GetAllDocumentsByKey(keyValue2,True) Set coll= view.GetAllDocumentsByKey(keyValue,True) Set coll9=view9.GetAllDocumentsByKey(keyValue,True) Set coll9ByID=view9ByID.GetAllDocumentsByKey(keyValue2,True) Set collByID=viewByID.GetAllDocumentsByKey(keyValue2,True) If collbyid.Count > 0 Then Set collDOC = collByID.GetFirstDocument collDate = collDOC.GetItemValue("Date") Dim tmpDate As New NotesDateTime( collDate(0) ) While Not (collDOC Is Nothing ) collDate = collDOC.GetItemValue("Date") Set colldate = New NotesDateTime(collDate (0)) If collDate.LSLocalTime < tmpDate.LSLocalTime Then Set tmpDate = New NotesDateTime(collDate.DateOnly) End If Set collDOC = collByID.GetNextDocument( collDOC ) Wend End If If Archcoll.Count > 0 Then Dim Archcolldoc As NotesDocument Set Archcolldoc = Archcoll.GetFirstDocument ArchcollDate = Archcolldoc.GetItemValue("Date") While Not (Archcolldoc Is Nothing ) ArchcollDate = Archcolldoc.GetItemValue("Date") Set Archcolldate = New NotesDateTime(ArchcollDate (0)) If Archcolldate.LSLocalTime < tmpDate.LSLocalTime Then Set tmpDate = New NotesDateTime( Archcolldate.dateOnly) End If Set ArchcollDOC = Archcoll.GetNextDocument( ArchcollDOC ) Wend End If If Not ( tmpDate Is Nothing) Then Dim dateTime180 As New NotesDateTime( tmpDate.DateOnly ) Call dateTime180.AdjustDay( 180 ) End If Dim actType As String actType = uidoc.FieldGetText("TypeActivity") actType = Left(actType, 1) '"""""""""63-0 with archive included'''''''''''''''''''''''' If actType = "9" And Not ( tmpDate Is Nothing) Then Set strDate = New NotesDateTime(strDate) If (strdate.LSLocalTime >= tmpDate.LSLocalTime) And (strdate.lslocaltime <= dateTime180.LSLocalTime) Then Dim view630 As NotesView Set view630 = curDb.GetView("(63-0 by ID)") 'by pat ID Dim coll630 As NotesDocumentCollection Set coll630 = view630.GetAllDocumentsByKey(strID2) Dim doc630 As NotesDocument If coll630.Count >0 Then Set doc630 = coll630.GetFirstDocument Dim dt630 As Variant While Not (doc630 Is Nothing) dt630 = doc630.GetItemValue("Date") Set dt630 = New NotesDateTime(dt630(0)) If (dt630.LSLocalTime >= tmpDate.LSLocalTime) And (dt630.LSLocalTime <= dateTime180.LSLocalTime) Then '2 message = Msgbox ("Both 63-0 and 63-9 are not allowed for the same client within a 180-day period." , _ 0+16+0+0, "HIV/AIDS Waiver Case Management") Call uidoc.FieldClear("TypeActivity") Exit Sub End If Set doc630 = coll630.GetNextDocument(doc630) Wend End If Dim viewArch630 As NotesView Set viewArch630 = ArchiveDb.GetView("(63-0 by ID)") 'by pat ID Dim collArch630 As NotesDocumentCollection Set collArch630 = viewArch630.GetAllDocumentsByKey(strID2) Dim docArch630 As NotesDocument If collArch630.Count >0 Then '1if Set docArch630 = coll630.GetFirstDocument Dim dtArch630 As Variant While Not (docArch630 Is Nothing) dtArch630 = docArch630.GetItemValue("Date") Set dtArch630 = New NotesDateTime(dtArch630(0)) If (dtArch630.LSLocalTime >= tmpDate.LSLocalTime) And (dtArch630.LSLocalTime <= dateTime180.LSLocalTime) Then '2nd if message = Msgbox ("Both 63-0 and 63-9 are not allowed for the same client within a 180-day period." , _ 0+16+0+0, "HIV/AIDS Waiver Case Management") Call uidoc.FieldClear("TypeActivity") Exit Sub End If Set docArch630 = collArch630.GetNextDocument(docArch630) Wend End If End If End If '"""""""""63- 0 with arch'''''''''''''''''''''''' '"""""""""63-9'''''''''''''''''''''''' If actType = "0" And Not ( tmpDate Is Nothing) Then Set strDate = New NotesDateTime(strDate) 'njr If (strdate.LSLocalTime >= tmpDate.LSLocalTime) And (strdate.lslocaltime <= dateTime180.LSLocalTime) Then Dim view639 As NotesView Set view639 = curDb.GetView("(63-9 by ID)") 'by pat ID Dim coll639 As NotesDocumentCollection Set coll639 = view639.GetAllDocumentsByKey(strID2) Dim doc639 As NotesDocument If coll639.Count >0 Then Set doc639 = coll639.GetFirstDocument Dim dt639 As Variant While Not (doc639 Is Nothing) dt639 = doc639.GetItemValue("Date") Set dt639 = New NotesDateTime(dt639(0)) If (dt639.LSLocalTime >= tmpDate.LSLocalTime) And (dt639.LSLocalTime <= dateTime180.LSLocalTime) Then message = Msgbox ("Both 63-0 and 63-9 are not allowed for the same client within a 180-day period." , _ 0+16+0+0, "HIV/AIDS Waiver Case Management") Call uidoc.FieldClear("TypeActivity") Exit Sub End If Set doc639 = coll639.GetNextDocument(doc639) Wend End If Dim viewArch639 As NotesView Set viewArch639 = ArchiveDb.GetView("(63-9 by ID)") 'by pat ID Dim collArch639 As NotesDocumentCollection Set collArch639 = viewArch639.GetAllDocumentsByKey(strID2) Dim docArch639 As NotesDocument Set docArch639 = coll639.GetFirstDocument If collArch639.Count >0 Then Dim dtArch639 As Variant While Not (docArch639 Is Nothing) dtArch639 = docArch639.GetItemValue("Date") Set dtArch639 = New NotesDateTime(dtArch639(0)) If (dtArch639.LSLocalTime >= tmpDate.LSLocalTime) And (dtArch639.LSLocalTime <= dateTime180.LSLocalTime) Then '2nd if message = Msgbox ("Both 63-0 and 63-9 are not allowed for the same client within a 180-day period." , _ 0+16+0+0, "HIV/AIDS Waiver Case Management") Call uidoc.FieldClear("TypeActivity") Exit Sub End If Set docArch639 = collArch639.GetNextDocument(docArch639) Wend End If End If End If '"""""""""63-9'''''''''''''''''''''''' ' ******************** This prevents 63 0/9 from being saved w/o 63-8 If coll.count = 0 And( ActivityCode ="63 - 0 " Or ActivityCode ="63 - 9 " ) Then message = Msgbox ("This patient does not have an SSR coded to 63-8 for " & strDate1 & "." , _ 0+16+0+0, "HIV/AIDS Waiver Case Management") Call uidoc.FieldClear("ServiceArea") Call uidoc.FieldClear("TypeActivity") Exit Sub End If ' ******************* This prevents a dupilcate 63-8 from being saved for t/same date Dim ID As String Dim currID As String If coll.count >= 1 And (activityCode = "63 - 8 ") Then Set doc =coll.GetFirstDocument Set uidoc=ws.CurrentDocument ID=doc.UniversalID currID=uidoc.Document.UniversalID If ID <> currID Then message = Msgbox ("This patient already has an SSR coded to 63-8 for " & strDate1 & "." , _ 0+16+0+0, "HIV/AIDS Waiver Case Management") Call uidoc.FieldClear("ServiceArea") Call uidoc.FieldClear("TypeActivity") End If Exit Sub End If ' ******************************* This prevents 62 from being saved w/o 63-0/9 If (coll.count = 1And coll9.Count =0) And( ActivityCode ="62 - 1 " Or ActivityCode = "62 - 4 ") Then message = Msgbox ("Service Area 63 - Activity Type 0 or 9 for "& strDate1 &" must be used prior to transitioning the client to Service Area 62.", _ 0+16+0+0, "HIV/AIDS Waiver Case Management") Call uidoc.FieldClear("ServiceArea") Call uidoc.FieldClear("TypeActivity") Exit Sub End If If (coll.count = 1) And ( ActivityCode ="63 - 0 " Or ActivityCode ="63 - 9 ") Then Set doc= coll.GetFirstDocument Dim hours As Variant Dim min As Variant hours = doc.GetItemValue ("Hours" ) min = doc.GetItemValue ("Minutes") Call uidoc.fieldsettext("Hours", Cstr(hours(0))) Call uidoc.fieldsettext("Minutes",Cstr(min(0) )) Exit Sub End If Exit Sub Dim ID9 As Variant Dim currID9 As Variant If coll9.count >= 1 And (ActivityCode = "63 - 9 " Or ActivityCode = "63 - 0 " ) Then Set doc = coll9.GetFirstDocument Set uidoc= ws.CurrentDocument strTypeActivity = doc.GetItemValue(Cstr("TypeActivity")) strTypeActivity = Left$(strTypeActivity(0),1) ' ******************* This prevents a dupilcate 630 / 639 from being saved for t/same date ID9=DOC.UniversalID currID9 =uidoc.Document.UniversalID If ID9<>currID9 Then message = Msgbox ("This patient already has an SSR coded to 63-" & strTypeActivity &" for " & strDate1 & "." , _ 0+16+0+0, "HIV/AIDS Waiver Case Management") Call uidoc.FieldClear("ServiceArea") Call uidoc.FieldClear("TypeActivity") End If End If Exit Sub End Sub
ASKED: November 13, 2008  2:04 PM
UPDATED: November 17, 2008  6:18 PM

Answer Wiki

Thanks. We'll let you know when a new response is added.

Try taking the “message=” out of your MessagBox call.

Discuss This Question: 1  Reply

 
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
  • Ledlincoln
    No, the "message=" should be okay. I would say that "If (dt630.LSLocalTime >= tmpDate.LSLocalTime) And (dt630.LSLocalTime <= dateTime180.LSLocalTime) Then" is never true. Check the date-time values your code is generating.
    1,620 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