Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: Ken Murphy
  Where is Ken Murphy?
 Springhill
 Canada
 Ken Murphy
 To: Kevin
  Where is Kevin?
 edwardsville
 Illinois - United States
 Kevin
 Tags
Subject: RE: Table setup
Thread ID: 118706 Message ID: 155050 # Views: 1 # Ratings: 0
Version: Visual FoxPro 9 Category: Visual Basic
Date: Saturday, December 22, 2007 10:13:22 PM         
   


> >
> > Kevin
> >
> > Use a GridCursor (or as Andy calls it, Safe Select) for your recordsource.
> >
> > In the form's .load() create your grid cursor using this:
> >
> >
> > SELECT Options.*, Optionsmodel.model as modelindex, Optionsmodel.option,  .f. AS lSelected ;
> >    FROM Optionsmodel ;
> >    RIGHT OUTER JOIN Options ON Options.index == Optionsmodel.Option ;
> >    WHERE .f. ;
> >    INTO CURSOR optionscursor READWRITE
> > 

> >
> > This will give you an empty readwrite cursor that you can then bind to your grid. Now create a custom form method and call it ".RepopulateGrid()" or what ever. In that custom method:
> >
> >
> > *  SELECT the records you need into a temporary cursor
> > SELECT Options.*, Optionsmodel.model as modelindex, Optionsmodel.option,  .f. AS lSelected ;
> >    FROM Optionsmodel ;
> >    RIGHT OUTER JOIN Options ON Options.index == Optionsmodel.Option ;
> >    WHERE Optionsmodel.Model = Model.index;
> >    INTO CURSOR Junk NOFILTER
> > *  Now clear any existing records from your grid cursor
> > SELECT OptionCursor
> > ZAP IN SELECT([OptionCursor])
> > *  and then populate your grid cursor with the records you just selected.
> > APPEND FROM DBF([Junk])
> > *  Don't need "Junk" any more so get rid of it
> > USE IN SELECT([Junk])
> > 

> >
> > The reason your columns get screwed up is when you run your SELECT, VFP closes your OptionCursor and recreates it from scratch. When the OptionCursor dissapears, because it is bound to your grid, your grid columns dissapear. With this method, your OptionCursor never gets closed - it just becomes empty for a bit, so your columns remain intact.
> >
> > Ken
> > You shall know the truth - and the truth shall set you free. (John 8:33)
>
> ok Thanks My grid is working. I can populate it with the options I have manually put in the Optionsmodel table.
> The new challenge is to create a form that we talked about earlier that will have a model drop down then a grid with all of the possible options so you can place a check in a column of the options that available for that model. Then save all the selections. Then later when you bring up the same model on the form it will show all of the selected options and all of the ones that are not selected.
>
> I am on a learning curve with the select statements I have used them in the past but in limited way. When ever I was changing data I would use a buffered table and change the data the save it. I am unclear how you get the data with select then save it back??
>
> As always you are a HUGE help!

The dropdown will give you the Model. You can use a SELECT statement to get your dropdown's rowsource as well. Once you have the model, you repopulate your grid and you are good to go. Saving the data back is no problem. You simply use an UPDATE or INSERT command. Scan your grid cursor and then INSERT INTO or UPDATE as appropriate. Give it a go and if you run into problems, post your code.

Ken
You shall know the truth - and the truth shall set you free. (John 8:33)

ENTIRE THREAD

Table setup Posted by krbaugh baugh @ 1/16/2007 11:41:24 PM
RE: Table setup Posted by Ken Murphy @ 1/17/2007 4:44:37 AM
RE: Table setup Posted by krbaugh baugh @ 1/17/2007 5:20:06 AM
RE: Table setup Posted by Ken Murphy @ 1/17/2007 1:35:18 PM
RE: Table setup Posted by krbaugh baugh @ 1/17/2007 4:15:33 PM
RE: Table setup Posted by Ken Murphy @ 1/17/2007 5:55:13 PM
RE: Table setup Posted by Kevin @ 12/20/2007 7:56:14 AM
RE: Table setup Posted by Ken Murphy @ 12/20/2007 2:01:49 PM
RE: Table setup Posted by Kevin @ 12/20/2007 3:34:16 PM
RE: Table setup Posted by Ken Murphy @ 12/20/2007 3:53:09 PM
RE: Table setup Posted by Kevin @ 12/20/2007 7:23:00 PM
RE: Table setup Posted by Ken Murphy @ 12/20/2007 8:31:13 PM
RE: Table setup Posted by Kevin @ 12/21/2007 7:18:26 AM
RE: Table setup Posted by Ken Murphy @ 12/21/2007 1:50:29 PM
RE: Table setup Posted by Kevin @ 12/21/2007 11:57:03 PM
RE: Table setup Posted by Ken Murphy @ 12/22/2007 2:32:13 AM
RE: Table setup Posted by Kevin @ 12/22/2007 5:02:58 PM
RE: Table setup Posted by Ken Murphy @ 12/22/2007 10:13:22 PM
RE: Table setup Posted by Andy Kramek @ 1/17/2007 12:38:25 PM