Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Need help with calling response form.

Posted on 2001-06-21
13
Medium Priority
?
235 Views
Last Modified: 2013-12-18
I have a database which will be used to setup production machines and record actual run condition values.  Each variable has a Min, Target, Max and Actual.  If the actual is outside the range of the min and max I want to call a deviation form which allows the value to remain if completed.  If not completed it returns the user back to the field and they can either change the value to be within the acceptable range or complete the deviation.

Everything works great except that I get two messageboxes asking the user if they want to deviate with the script as written below.  The issue is that the code acts on entering and exiting.  When the user tabs from the first variable the exiting routine brings up the messagebox for field 1, If the user says no, the exiting for field 2 brings up the messagebox again this time for field two, if the user says no they are returned to field 1.

Code is as follows:

Sub Entering(Source As Field)
     Dim ws As New NotesUIWorkspace
     Dim uidoc As NotesUIDocument
     Dim note As NotesDocument
     
     Set uidoc = ws.CurrentDocument    
     Set note = uidoc.Document
     
     CurField=uidoc.CurrentField
End Sub

Sub Exiting(Source As Field)
     Dim ws As New NotesUIWorkspace
     Dim uidoc As NotesUIDocument
     Dim note As NotesDocument
     
     Set uidoc = ws.CurrentDocument
     Set note = uidoc.Document
     
     If Field1Var = 1 Then Exit Sub
     
     If note.Field1Actual(0) < note.Field1Min(0) Or
        note.Field1Actual(0) > note.Field1Max(0) Then
          If Msgbox( "Do you want to deviate?", 4 +
             32, "Process Deviation" ) = 6 Then
               Field1Var = 1
               Call uidoc.Save
               Call ws.ComposeDocument( "","","Run
                    Condition Deviation" )
          Else
               Call uidoc.GotoField(CurField)
          End If
     End If
End Sub

So in summary, my problem is that I get the message box twice, once requesting the deviation for Field1 due to the value being outside the range (as I want) and once for Field2 because Field2 is empty and therfore outside the range before being returned back to Field1.

Any help would be appreciated.
0
Comment
Question by:jgange
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
13 Comments
 
LVL 24

Expert Comment

by:HemanthaKumar
ID: 6216469
Introduce a new global variable like this

Dim ValidationFailed as Variant

In your FIELD1 exit the code will look like

     Dim ws As New NotesUIWorkspace
     Dim uidoc As NotesUIDocument
     Set uidoc = ws.CurrentDocument
     validationFailed = True
     If Msgbox( "Do you want to deviate?", 4 + 32, "Process Deviation 1" ) = 6 Then
          validationFailed = False    
     End If
     If validationFailed  Then     Call uidoc.GotoField("FIELD1")

In your FIELD2 exit the code will look like

Sub Exiting(Source As Field)
     Dim ws As New NotesUIWorkspace
     Dim uidoc As NotesUIDocument
     Set uidoc = ws.CurrentDocument
     
     If validationFailed Then    
          Call uidoc.GotoField("FIELD1")
          Exit Sub
     End If
     If Msgbox( "Do you want to deviate?", 4 + 32, "Process Deviation 2" ) = 6 Then
          validationFailed = False    
     End If
     
End Sub

I havent tested thoroughly of other possibility, but it doesn't show two msgs. Let me know if you have any other questions.


~Hemanth
0
 

Author Comment

by:jgange
ID: 6218140
One key is that this has got to work when going to any field from any field.  I don't believe that the code as written does this.

Example
Field1minvalue  Field1targetvalue  Field1maxvalue  Field1actualvalue
Field2minvalue  Field2targetvalue  Field2maxvalue  Field2actualvalue
Field3minvalue  Field3targetvalue  Field3maxvalue  Field3actualvalue
continues... through about 40-50 fields

The min, target, and max fields contain data which is inherited from another form and are uneditable.  The user looks at their machine and enters the actualvalue then tabs to the next field.  But they also may use their mouse and skip a couple fields so I need the code to be general and return them to the field where they last were and force them to deviate or put in a value within the acceptable range (which all works currently) and get rid of this bug of two messageboxs (what I need help on), one for the field they left and the second from leaving the field they clicked to due to the exiting routine forcing them back to the original field.
0
 
LVL 3

Expert Comment

by:Joep8020
ID: 6218272
the problem arises I think because when you are in the exiting event, the cursor already is in the next field, therefore the entering event was already triggered. So when you save the uidoc, all exiting events are triggered.

Solution: at the beginnning of the exiting event set a public variable to the name of the field. At the end of the exiting event clear this variable.

In all entering events only execute the code if the variable = empty.

Success
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

Author Comment

by:jgange
ID: 6218336
One key is that this has got to work when going to any field from any field.  I don't believe that the code as written does this.

Example
Field1minvalue  Field1targetvalue  Field1maxvalue  Field1actualvalue
Field2minvalue  Field2targetvalue  Field2maxvalue  Field2actualvalue
Field3minvalue  Field3targetvalue  Field3maxvalue  Field3actualvalue
continues... through about 40-50 fields

The min, target, and max fields contain data which is inherited from another form and are uneditable.  The user looks at their machine and enters the actualvalue then tabs to the next field.  But they also may use their mouse and skip a couple fields so I need the code to be general and return them to the field where they last were and force them to deviate or put in a value within the acceptable range (which all works currently) and get rid of this bug of two messageboxs (what I need help on), one for the field they left and the second from leaving the field they clicked to due to the exiting routine forcing them back to the original field.
0
 
LVL 24

Accepted Solution

by:
HemanthaKumar earned 800 total points
ID: 6218650
Ok you asked for general piece and here is the general script for your task

In Global declare these variables & Sub

Dim curField As String
Dim validationFailed As Variant

Sub Validate_Enter(Source As Field)
     Dim ws As New NotesUIWorkspace
     Dim uidoc As NotesUIDocument
     Dim note As NotesDocument
     
     Set uidoc = ws.CurrentDocument    
     Set note = uidoc.Document
     ValidationFailed = False
     CurField=uidoc.CurrentField
End Sub

Sub Validate_Exit(Source As Field)
     Dim ws As New NotesUIWorkspace
     Dim uidoc As NotesUIDocument
     Dim note As NotesDocument
     
     Set uidoc = ws.CurrentDocument
     Set note = uidoc.Document
     
     If ValidationFailed Then Exit Sub
     
     FIELDVal = note.GetFirstItem(CurField).Values(0)
     
     If FieldVal < note.FieldMin(0) Or FieldVal > note.FieldMax(0) Then
          If Msgbox( "Do you want to deviate?", 4 + 32, "Process Deviation" ) = 6 Then
Call uidoc.Save
               Print {ws.ComposeDocument( "","","Run Condition Deviation" )}
          Else
               ValidationFailed = True
               Call uidoc.GotoField(CurField)
          End If
     End If    
End Sub

IN YOUR FIELD ENTER AND EXIT USE THIS

Sub Entering(Source As Field)
     Call Validate_Enter(Source)
End Sub

Sub Exiting(Source As Field)
     Call Validate_Exit(Source)
End Sub


This should work for any number of fields

~Hemanth
0
 

Author Comment

by:jgange
ID: 6232668
Hemanth,

I don't understand one thing.

In the line below how would the min and max values get read in without hard coding the field names which means I can't do this globally?

If FieldVal < note.FieldMin(0) Or FieldVal > note.FieldMax(0) Then
0
 
LVL 24

Expert Comment

by:HemanthaKumar
ID: 6232810
min and max can also be passed as an parameter to the function.

But in your case if it has more than one min and max field then

In the Exit event of the field pass the min max value to be compare

like

min = note.Field1Min(0)
max = note.Field1Max(0)
Validate_Exit( Source, min , max)

& sub will accept three parameters instead of one

like

Sub Validate_Exit(Source As Field, min as variant, max as variant)
   

& if condition will be

If FieldVal < min Or FieldVal > max Then

Hope it is clear

~Hemanth
0
 

Author Comment

by:jgange
ID: 6234970

Notes seems so buggy to me it is frustrating.

Over the last few days I have been struggling with the fact that if I respond yes to the messagebox, complete the deviation and then go the next field and then if that value is out of range and I resond No if puts back to the earlier field, not the one that I am in like it is supposed to.  The reason as best I can tell is because the Entering routine is not running consistently which resets the CurField.

Jason
0
 

Author Comment

by:jgange
ID: 6235696

OK, working with the debugger I just figured out what is happenning, notice I didn't say why.  For a No answer to the messagebox in the code above the exit event for the next field is run without having run the enter event on that field.

Here is what I see for an out of range value.

Step 1
  Enter Event Runs on Field 1
Step 2
  Exit Event Runs on Field 1 (NO Answer is then selected)
Step 3
  Exit Event Runs on Field 2
Step 4
  Remaining part of Exit event runs on Field 1
Step 5
  Enter event runs on Field 1

This would make sense to me if Step 3 was the enter event for Field 2 and I understood why only half the Exit event runs on Step 2.

But I am getting closer....
0
 
LVL 24

Expert Comment

by:HemanthaKumar
ID: 6235803
Remember you pressed tab or clicked into field2, that is why field2 is firing the events, accordingly. The script doesn't control the action. It only checks for the flags and acts , a simulation.

Enter event is also fired but in a split second for field2



0
 

Author Comment

by:jgange
ID: 6237984
Are you sure that the Enter event is also fired.  I have break points at the begginning of all Enter and Exit events and for a NO answer the Enter event is never shown for Field 2.  I repeated this twice including logining out and back into the database to be sure.  For a YES answer and for a in spec value the Enter event for field 2 is run but for a NO answer it is skipped????
0
 
LVL 63

Expert Comment

by:Zvonko
ID: 10476239
jgange,
No comment has been added lately (974 days), so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area for this question:

RECOMMENDATION: Award points to HemanthaKumar http:#6218650
Please leave any comments here within 4 days.

-- Please DO NOT accept this comment as an answer ! --

Thanks,

Zvonko
EE Cleanup Volunteer
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Notes Document Link used by IBM Notes is a link file which aids in the sharing of links to documents in email and webpages. The posts describe the importance and steps to create a Lotus Notes NDL file in brief.
This article covers general Notes 8.5 troubleshooting information including recreating the Notes\Data folder.
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…

722 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question