Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Appending to views
Message
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00116402
Message ID:
00120758
Vues:
23
Michelle,

Maybe I can consolidate some of this thread in a way that might help.

Views are just like cursors with the benefit that they can be made updateable. You can use them on forms or in reports to your hearts content. The fact that they can be put into the DBC makes them more universally available and therefore a little easier to use that cursors. Don't worry about the little bit of additional "overhead" that a view has compared to a plain cursor.

You have clients that is one-to-many to trips, trips has two links into location. Create an updateable view on trips, the location fields do not have to be updateable. All you are doing is changing the two FKs into the location table.

A read only view might look like:
select trips.dWhen ;
   PickUp.Loc as cPickUp ;
   DropOff.Loc as cDropOff
   from trips ;
      inner join location as PickUp ;
         on trips.iPickUpFK = location.PK ;
      inner join location as DropOff ;
         on trips.iDropOffFK = location.PK
   where trips.iClientFK = ?clients.PK ;
   order by dWhen
This will pull in the location.Loc (which I assume is like a city name instead of it's PK value)

To edit your trips grid I'd just create a cbo subclass something like:
select location.Loc, location.PK ;
   into this.maItems ;
   order by Loc
I would only use a cbo if you are talking about tens of locations, maybe a couple of hundred. If you have thousands I'd give them some sort of grid to choose laction from.

The updateable view does not have to be joined to location it's just a much simpler parameterized view:
select * ;
   from trips 
   where trips.iClientFK = ?clients.PK
In the grid replace the textbox for the trips.iPickUpFK and trips.iDropOffFK fields with the cbo subclass and then they can select whatever location they want for PickUp and DropOff.

If you want to allow them to also add new locations from here I'd maybe do that on another page or with another child form.

>Well, I can't speak from experience until I've done some reports with views, but the instructor was doing some cool things with veiws for reports. Much better than scanning through a table, searching another, adding this and that...
>
>Maybe I'm missing something. Here's a summary:
>
>I have a clients table, a trips table, and a locations table. On the form, the clients table is the main one. The trips table is in a grid, linked to the clients table by CLIENTKEY. The locations table is linked to the trips table in two places: PICKUP and DROPOFF. In the grid, I want all the records from trips to show, but I want LOC from locations to show in place of both PICKUP and DROPOFF.
>
>I've decided to make the grid read-only, so that saves some hassle. But I want the user to be able to click on a record in the grid, click on the view button, and have another form come up.
>
>This new form has trips as the main table. There is no grid. Also on the form is the pickup and dropoff. But instead of the key numbers being displayed, I want several textboxes that contain the complete location information that matches the PICKUP and DROPOFF fields.
>
>The trip needs to be updatable. The location needs to be updatable. When the location is edited, it is to append a new record to the locations table, not change what's there. The new location key is then placed in PICKUP or DROPOFF, depending on which location was edited.
df (was a 10 time MVP)

df FoxPro website
FoxPro Wiki site online, editable knowledgebase
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform