Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to set up views from dynamically filtered data? 2

Status
Not open for further replies.

EMJULIAN

Programmer
Aug 14, 2002
45
US
I have a form with 4 grids, each connected to a table, we'll call them A,B,C and D. Table A and B are filtered to show only the data for a particular dataset. Clicking on table A will cause table C to be filtered to that data, and clicking on table B will further refine the filter for table C. Table D is filtered on the same dataset as table A, and clicking on table B will further filter the data. Confused yet? [dazed]

Here's what I need: I want to use views to populate my grids with so that the scroll bars work correctly on the grids and I can update the tables as I go. To contain these views I need a temporary database (I don't use databases with my program currently). My question is - how do I create views that will give me only the filtered data, and that will change as the filters change (which depends on which line of which grid they are sitting on). Short version - how do I create views that reflect the dynamic filters applied to the parent table? Should I do it programmaticly or with the view designer?

Thanks for you help - I'm sure this is about as clear as mud!

Eve
 
I think the best solution is to create the filters programmatically. Once you issue 'SET FILTER TO &&somefilter' only records that meet your filter condition will be displayed. You can issue a separate SET FILTER for every table/view that is open. Make sure after you issue a set filter you use GOTO TOP or some other record navigation code, since the filter isn't evaluated until the record pointer is moved.

As far as I know, if you were to create a parameterized view instead. Then you would be limited to the filters set inside the view. I do not think you can change them on the fly.

Hope this helps.

-Kevin
 
Eve,

Although I don't disagree with Kevin's advice, my inclination would be to go with a parameterised view instead.

In general, you can create a parameterised view in the view designer. In the Filter tab, enter the condition, based on the field that you want to filter. In the Example column, enter the name of a variable which holds the filter value, and precede this name with a ?

For example, if you were filtering on the City field, and the variable lcCity contains the target city name, the filter would be:

MyTable.City = ?lcCity

Next, each time the target city changes (when the user is interacting with one of the grids), store the new taget city in lcCity, and requry the parameterised view:

REQUERY("MyView")

You'll also need to set focus on the grid (the one bound to the parameterised view) to make the change visible.

Hope this is clear.

Mike


Mike Lewis
Edinburgh, Scotland

My Visual Foxpro web site: My Crystal Reports web site:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top