main logo
Subject: Re: How do I modify a view
Author: Bill Young
Posted: 2001/07/07 01:16:02
 
View Entire Thread
New Search


<i><font color="#663300">I have a local view without parameters. It just shows the user a list of patients to be selected from. It has no Where clause. The patient clicks on a name in the list and they get the patient's record. I use filters to allow the user to search by specific fields.

I want to incorporate an ad hoc Search function which will also populate this cursor. The user wll create the SQL statements for the query, and the results will populate the list of patients. There will be a Where clause. For example, the user might request a list of all patients who are female.

I want to be able to programatically modify the original view so that I can swap in Where statements one after the other, without getting prompted to save because the program has noticed the view has changed.

It seems the best way to do this is to temporarily modify the SQL statement that the cursor is based on (as opposed to say, deleting and appending to the list of patients from a separate Search cursor).

This will allow a requery from the toolbar to propery refresh the view, regardless of the Where clause.

Is there an appropriate 'Codebook' way of doing this?</font></i>

Paul -

Create your view in VFP programatically by using the macro &lcWhere for your WHERE statement. In the INIT() method of the ODELOADER for the ebizobj underneath your list object, set lcWhere = '.T.'. Then when it opens the view, it will return all of the records. You then have a textbox somewhere that allows you to change the value of lcWhere to the filters you need (you will have to do some validation of the statement to make sure it is syntactically correct as a substitute WHERE clause). For instance the textbox will read after certain items are selected:

Gender = 'F' AND Zip = '90005'.

In the click event you would surround this value in brackets [Gender = 'F' AND Zip = '90005'] and reset the value of lcWhere. After lcWhere is redefined you pass it by the REQUERY() method of the ebizobj and refresh the gridlist. That should give you what you need. There is no danger of getting a 'Change' message since you haven't allowed any of the values in the view to change requiring a save. I think that this will work.

HTH,

Bill
Bill Young
CySolutions
wjy /at/ cysolutions .D.OT com
 
©2001 Bill Young
<-- Prior Message New Search Next Message -->