Wiki Home

PCForm


Namespace: People
Here is an example of using 2 parameterized views on a form.
  1. Run mkDbc to build the dbc and have some sample data.
  2. CREATE FORM PCFORM
    1. Form, Edit Property/Method
      1. New Property, Name: k_Insp, Close
      2. New Method, GetShowData (caps won't show), Close
      3. Close
    2. code for .GetShowData():
      ReQuery( "v_Insp_One" )
      ReQuery( "v_Store_Childs" )
      thisform.Refresh()
    3. View, Data Environment
    4. Switch to Views, add the 2 views, Close.
    5. set .NoDataOnLoad to .f. for both
    6. add a texbox to the form,
      1. set .Control to thisform.k_Insp
      2. set .valid thisform.GetShowData()
    7. Drag cResults from the DE onto the form, drop it below the k_insp textbox. when it asks for a value for thisform.k_insp, enter 1, hit ok. (does anyone know how to surpress that?)
    8. Drag the c_Store_Childs Cursor Object (the view in the DE) onto the form. Enter 1, hit ok. (grrr..)
Hit Ctrl+E to run the form. enter 1 in the box and hit enter, then 2, 3, 4, 5.

* Program mkDbc
SET Safety OFF
CLOSE DATABASES 
DELETE DATABASE PCEF DELETETABLES

mkDbfs()
mkDbc()

FUNCTION mkdbfs
CREATE TABLE insp ( ;
	pk_Insp i, ;
	cResults c(30) )

CREATE TABLE store ( ;
	pk_store i, ;
	fk_Insp i, ;
	cName c(30) )
	
INSERT INTO insp VALUES ( 1, "insp1" )
INSERT INTO insp VALUES ( 2, "insp2" )
INSERT INTO insp VALUES ( 3, "insp3" )
INSERT INTO insp VALUES ( 4, "insp4" )

INSERT INTO store VALUES ( 1, 1, "store A" )
INSERT INTO store VALUES ( 2, 1, "store B" )
INSERT INTO store VALUES ( 3, 1, "store C" )

INSERT INTO store VALUES ( 4, 2, "store D" )
INSERT INTO store VALUES ( 5, 2, "store E" )
INSERT INTO store VALUES ( 6, 2, "store F" )
INSERT INTO store VALUES ( 7, 2, "store G" )

INSERT INTO store VALUES ( 8, 4, "store H" )

return

FUNCTION mkdbc

CREATE DATABASE pcef

CREATE sql VIEW v_insp_one as ;
	select * ;
	from Insp ;
	where pk_Insp = ?thisform.k_Insp

CREATE sql VIEW v_Store_childs as ;
	select * ;
	from store ;
	where fk_Insp = ?thisform.k_Insp
	
return

Q: What do you think the best parameter is for the view? thisform.k_insp ties a data object to the UI, and that is not n-tier.

Q: How do I keep the view from wanting a parameter when things are dragged onto the form?
Contributors: Carl Karsten
Category Code Samples
( Topic last updated: 2001.04.14 03:33:08 PM )