[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

QuerySave Continue condition not working

Posted on 2006-06-08
7
Medium Priority
?
731 Views
Last Modified: 2013-12-18
Hi,

I'm using Notes R5 and I stimply want to cancel the save operation based on a certain condition. However, I get the messagebox that says I must enter a report number however, the Continue = False statement doesn't prevent the save process. Am I missing something. Here is a snipplet:

Sub Querysave(Source As Notesuidocument, Continue As Variant)
      Dim WS As New NotesUIWorkspace
      Dim Session As New NotesSession
      Set db = session.CurrentDatabase
      Set docA = WS.CurrentDocument
      
      If docA.fieldgettext("ContNum")="" Then
            Messagebox "You must enter a Report Number"
            Continue = False      
            Exit Sub
      End If
               .... More error checking
End Sub
0
Comment
Question by:Sarniait
  • 2
  • 2
5 Comments
 
LVL 46

Expert Comment

by:Sjef Bosman
ID: 16863008
Firstly, this kind of errorchecking/field validation should be handled on the field level.
Secondly, I avoid using NotesUIDocument. In this case that would result in:
    Dim doc As NotesDocument

    Set doc= ws.CurrentDocument.Document
    If doc.ContNum(0)="" Then
    ...

For the rest, it seems correct to me. You copied/pasted the code straight from the database?

One more thing that might help you: in the Options section of your form, add the line
    Option Declare

That line will enforce a declaration for every variabale. Handy when you can't find a typo...
0
 

Author Comment

by:Sarniait
ID: 16863357
Bosman,

Ok so I might be over complicating what I really need, which is validation. I'm not a notes developer nor do I pretend to be one =), so this might be a stupid/simple question. How do you preform field validation at the "field level"?
0
 
LVL 46

Accepted Solution

by:
Sjef Bosman earned 1000 total points
ID: 16864194
Not pretending to be one? Is that so? ;)

Every field has a Validation 'event', the result of which has to be either @Failure or @Success.

Standard for a required field:
    @If(@Text(@ThisValue)=""; @Failure("Required field"); @Success)
and the cursor will be placed in the field.
0
 

Author Comment

by:Sarniait
ID: 16864344
Interesting. I don't see this event in the event list for any field. Could this be a feature in newer versions?
0
 
LVL 18

Assisted Solution

by:marilyng
marilyng earned 1000 total points
ID: 16867057
In addition to sjef's field validation checking at the field level (BTW, I usually don't do this, I use the query save, but depends)
YOu don't need to instantiate uidoc since SOURCE does this automatically.  I haven't had problems with just setting doc without database or session for a quick validation:

Sub Querysave(Source As Notesuidocument, Continue As Variant)      
     Set docA = source.document
     
     If len(docA.getItemValue("ContNum")(0))=0 Then
          Messagebox "You must enter a Report Number"
          Continue = False    
          Exit Sub
     End If
               .... More error checking
End Sub

--------
Or you can do:
Sub Querysave(Source As Notesuidocument, Continue As Variant)      
         
     If len(source.fieldgetText("ContNum"))=0 Then
          Messagebox "You must enter a Report Number"
          Continue = False    
          Exit Sub
     End If
               .... More error checking
End Sub

Provided that the field "ContNum" is visible and editable, else you would have to use the backend doc to get the value.
-------------------------

If you're going to use the field validation and a button that does:  @Command([FileSave]);@Command([FileCloseWindow])

then you have to test for @isvalid first, else the button save will ramble on, in between the validation error messages.

So, the button formula:

@if(!@isValid;@Return("");"");
@if@Command([FileSave]);@Command([FileCloseWindow]);"")

0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

For users on the Lotus Notes 8 Standard client, this article provides information on checking the Java Heap size and adjusting it to half of your system RAM in attempt to get the Lotus Notes 8.x Standard client to run faster.  I've had to exercise t…
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 video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Suggested Courses

830 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