Formula Loop

In the postopen event of a form, I have a dialogbox pop up to fill in a field. Now, what I want is, for that box to keep popping up until the field is filled in just in case someone might just click on the x and close the dialog box window.  How do I do it?
schmad01Asked:
Who is Participating?
 
HemanthaKumarConnect With a Mentor Commented:
The field name cannot contain space like Proj Num... Is it ProjNum ??

If so..

     Dim db As NotesDatabase
     Dim s As New NotesSession
     Dim workspace As New NotesUIWorkspace
     Dim view As NotesView
     Dim doc As NotesDocument
     Set db = s.CurrentDatabase
     Set doc = db.CreateDocument
callDialog:
' Call the dialog box with doc as paremeter
Call workspace.DialogBox _
        ("Dialog Box", True, True, False, False, False,  _
     False, "Dialog Box", doc)

if doc.ProjNum(0) = "" then goto callDialog


0
 
HemanthaKumarCommented:
Here is a example

     Dim db As NotesDatabase
     Dim s As New NotesSession
     Dim workspace As New NotesUIWorkspace
     Dim view As NotesView
     Dim doc As NotesDocument
     Set db = s.CurrentDatabase
     Set doc = db.CreateDocument
callDialog:
' Call the dialog box with doc as paremeter
Call workspace.DialogBox _
        ("Dialog Box", True, True, False, False, False,  _
     False, "Dialog Box", doc)

if doc.FieldRequired(0) = "" then goto callDialog

~Hemanth
0
 
qwaleteeCommented:
Can't really do it directly in R5.  R6 has @formula looping mechanisms.

What you can do is set a flag field that indicates when the formula has reached completion, put @If(flag_set; @Return(COMPLETE); @PostedCommand([ViewRefreshFields])) at the top, and put a copy of the formula in PostRecalc, if it isn't already occupied.  That will cause the formula to exit immediately if it ever completed, but otherwise, force a recalc before it even starts.  Effectively, the formula keeps looping, because the reccalc does the same thing, forcing itself to run again immediately after it completes.
0
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
schmad01Author Commented:
Heman,
Please clarify, let's say the field name is field1. Where do I plug that in?
0
 
HemanthaKumarCommented:
That will be in the if condition

if doc.Field1(0) = "" then goto callDialog
0
 
Bozzie4Commented:
You'll need to use the 'source' uidocument, instead of creating a new document.
Put this in the postopen event :

Dim db As NotesDatabase
     Dim s As New NotesSession
     Dim view As NotesView
     dim returnValue as integer
    if source.isNewDoc then
Do While source.document.Field1(0) = "" 
returnValue = workspace.DialogBox _
        ("Dialog Box", True, True, False, False, False,  _
     False, "Dialog Box", doc)
if not returnValue then
' stop it here
' close the document if cancelled
source.document.saveoptions = "0" 'you may need to add a text field, saveoptions, editable, value "1", to the form
call source.close()
end if
end if
Loop


Here, the user can cancel too, and the document will close ...

cheers,

Tom
0
 
schmad01Author Commented:
Variant does not contain an object
0
 
schmad01Author Commented:
Sorry guys, getting problems or errors on both scripts as follows.

Heman's: The loop never stops. Dialog box won't go away, even when filled in.


Bozz : Unexpected Endif Expected Loop.
0
 
HemanthaKumarCommented:
Are you using correct field name ??? If not it always says that if condition is true and keeps looping .. check the spelling too
0
 
schmad01Author Commented:
Heman repost the correct code with these plugged in so I will know if I did it right.
The name of the field is proj num.  The name of the form with the layout region is projnum.

Thanks.
0
 
Bozzie4Commented:
Dim db As NotesDatabase
     Dim s As New NotesSession
     Dim view As NotesView
     dim returnValue as integer
    if source.isNewDoc then
Do While source.document.Field1(0) = "" 
returnValue = workspace.DialogBox _
        ("Dialog Box", True, True, False, False, False,  _
     False, "Dialog Box", doc)
if not returnValue then
' stop it here
' close the document if cancelled
source.document.saveoptions = "0" 'you may need to add a text field, saveoptions, editable, value "1", to the form
call source.close()
end if

Loop

end if
0
 
schmad01Author Commented:
Correct, the field name is actually proj_num.

Still getting error though.  Variant does not contain an object.
0
 
HemanthaKumarCommented:
switch on debugger and see which line is giving that error.
0
 
schmad01Author Commented:
I think it is this one.  if doc.ProjNum(0) = "" then goto callDialog

The dialog box pops up, I enter my value and then I can't get it to disappear.  I have to end task to close notes and then reboot.
0
 
HemanthaKumarCommented:
Can you post your code here..Also did you replace the field name properly ??
0
 
schmad01Author Commented:
Yep, I think I did. Here is the code:

Dim db As NotesDatabase
      Dim s As New NotesSession
      Dim workspace As New NotesUIWorkspace
      Dim view As NotesView
      Dim doc As NotesDocument
      Set db = s.CurrentDatabase
      Set doc = db.CreateDocument
callDialog:
' Call the dialog box with doc as paremeter
      Call workspace.DialogBox _
      ("projnum", True, True, False, False, False,  _
      False, "Assign Project Number", doc)
      
      If doc.proj_num(0) = "" Then Goto callDialog
0
 
HemanthaKumarCommented:
Can u send me the sample databas that has this forms and script ??
0
 
qwaleteeCommented:
Uh oh, EE violation.
0
 
schmad01Author Commented:
OK.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.