> >
> > Ok that is working! Thanks
> > Now my problem is the grid has somme moved columns
> >
> > When I do
> >
> > thisform.grid1.RecordSource =space(0)
> >
> >
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 optionscursor READWRITE
> > thisform.grid1.RecordSource =space(0)
> > thisform.grid1.RecordSource = "optionscursor"
> >
> > My data is in the wrong columns do I need to redo the select so the columns are in the order I need them on the grid then redo the grid so the columns are not rearranged?
>
> 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!