Lotus Notes FAQ Visit Our Sponsor!

Can you do a Query by Form?

Create a form named "Search Form" with simple text fields that will be used to refer to the Notes fields of the documents in the "Search View" below. Name these fields form_Field1 and form_Field2 which correspond to Notes fields named Field1 and Field2. Add a field named "SaveOptions" with a default value of "0" (with the quotes) so the form is not saved when submitted.

Put a $$Return field that is computed for display at the very top of your search form with a formula of:

  tField1 := @Trim(form_Field1);
  tField2 := @Trim(form_Field2);
  a := @If (tField1 = ""; ""; "([Field1] = " + tField1 + ")");
  b := @If(tField2 = ""; ""; "([Field2] = " + tField2 + ")");
  SearchFields := @Implode(@Trim(a:b); " AND ");
  REM " *** Empty search will return everything ***";
  SearchString := @If(SearchFields = ""; "*"; SearchFields );
  db := @Subset(@DbName; -1);
  view := "Search View";
  REM "*** Replace spaces with '+'s ***";
  SearchView := @Implode(@Explode(view; " "); "+");
  @Return("[/" + db + "/" + SearchView + "?SearchView&Query=" + SearchString + "]")

To initiate a search, provide a link somewhere that with Action hotspot of

  @Command([Compose]; "Search Form");


Applies to Notes Versions: 4 4.5 4.6 5
Last Modified: September 8, 1999