Program: Superbase Version: 2.0 Date: November 2, 1992 Topic: Query-By-Form using Superbase Summary: This technote addresses a different method of creating queries than the usual filter dialog, Quick Reports, or Query by Example (QBE). This method is generally referred to as Query-By-Form. It is a simple method of building queries providing a no training query interface for end-users. This technote takes advantage of the extra procedure libraries provided with Version 2.0 of Superbase to make an easy and intuitive query interface. Overview What makes this technique possible is a User-defined procedure called FilterByFile() provided with Superbase version 2.0. The procedure uses the current file and record to create a filter. This filter can be viewed by setting the second parameter to 1. Shown below is a simple example of using FilterByFile(). Example SBL code: OPEN FORM "test" LOAD "c:\sb4w\examples\procs\sblexten.sbp", NEW BLANK FORM ENTER CALL FilterByFile(0,0) SELECT FIRST FORM How it works OPEN FORM "test" Opens a form and its assorted data files. LOAD "c:\sb4w\examples\procs\sblexten.sbp", NEW Loads the procedure file SBLEXTEN.SBP into memory. The NEW keyword specifies that it should not replace the current program in the program editor. BLANK Creates a new empty record in memory. FORM Forces the screen to be refreshed with the empty record. ENTER Puts the user in the form so one can enter the query criteria. CALL FilterByFile(0,0) This is the routine in the procedure library that actually builds the filter that is used. The first parameter specifies if you want to exclude read-only (1 for yes, 0 for no). The second parameter specifies if you want the Filter dialog box to be displayed to the user after the routine builds the query filter from the current form (1 for yes, 0 for no). SELECT FIRST Sets the file pointer to the first selected record. FORM Displays the current record. Notes on using this example: * On a linked form, the filter works strictly off the master. * Since this technique takes advantage of creating a blank entry record in memory to hold the query data, this method is easier to implement if your data file definition has no unique indexes or required fields. Otherwise, special handling of query entry is required. * Also, the user should not be allowed to save the record they are entering for the query by form. This could be done by SET MENU OFF or by using a custom menu with the Save item disabled. * Very complex queries could be created using this example, so the user could trap for Query too Complex errors.