Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Views
Message
From
05/11/1998 02:58:20
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
04/11/1998 23:42:07
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Re: Views
Miscellaneous
Thread ID:
00154664
Message ID:
00154706
Views:
23
>I need help setting "views" in a form.
>I have a form with a page frame and two pages. One with detail records and another containing a grid.
>I need to be able to view the data, say Names.dbf, either completely or "filtered" to only those key values contained in a selected table whose name will vary, but call it the "Query" table. There is a whole set of "query" tables predefined that the use can choose from a popup. The popup is outside the pageframe, so can be changed either while details or the grid is displayed.
>
>So Names.dbf might contain fields pkey i, name c(40), town c(30)... etc, but all the query tables only contain a single field pkey i. Get the idea?
>
>So how do efficiently set up an editable view which is essentially either..
>
>SELECT * from Names where pkey in (select pkey from "query") && where "query" can change
>or
>all records in Names if user chooses no filter.
>
>I can handle the SQL but how do I parameterise the view expression?
>How do I change the source of the grid to match?
>
>You see if I did this in FPW 2.6 it's simple, it's fast, I wouldn't even need to run a query, just set a relationship from Query into Names, and that would work in the browse as well. But I'm not sure on the best approach in VFP.
>
>I'm sorry this is a complicated question, but it's a sort of design structure that comes up often in my sort of apps. So would really appreciate a jump start.
David,
Why not do it like FP 2.6 way - still with view :) Views are also indexable so create an index on PKid field (or PKid+defaultorderfield), set grid's linkmaster, childorder, relationalexpression fields.
* Old relation style
use child in 0 order tag myorder
select master  && Master is your query
set relation to pkid into child
* Correspond to
ChildOrder = "myOrder"
LinkMaster = "master"
RelationalExpression = "pkid"
recordsource = "child"
Say in fact you want to order names on dBirthDate. You would index view on pkid+dtos(dBirthDate) tag myOrder because just in old relation style (for me in fact not old, still lives :) you wouldn't change order of child to something that doesn't start with pkid (which is RelationalExpresion). This works fast and I use this way. OTOH w/o relation, all view style is possible too :) View's SQL expression would be a parameterized (pseudo) view.
SELECT * from Names ;
  where pkey in ;
       (select pkey from (thisform.tcQuery))
* Instead of hardcoding "query" now 
* custom form property "tcQuery" holds ref to needed table
* At first you could set tcQuery to "crsAllNames"
* In Form.load, DE.beforeopentables whereever applicable
* select pkid from names into cursor crsAllNames
* Anytime "query" table changes, you would simply
* put new "query" tablename into tcQuery and requery(cYourView)
* Grid.recordsource would always be the view itself
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform