>>>>>Hello Chaps
>>>>>
>>>>>This continuing problem I have of FPD2.6 tables (from a legacy, still used system) that I'm using in my replacement for the old system. For some reason, the author made Y/N char fields rather than logical. I want to display certain child recs in a grid, and allow edit thereof.
>>>>>
>>>>>I populate the grid in the following manner:
>>>>>
>>>>>With Thisform
>>>>> lcAlias = ALIAS()
>>>>> Select JNYSTAGE
>>>>> lcFilter = "OPERATOR = " + STR( .nOperator, 3, 0) + ;
>>>>> " and ROUTE = '" + .cRoute + "'" + ;
>>>>> " and MCL_RTE = '" + .cMCL_Rte + "'"
>>>>> Set Filter To &lcFilter
>>>>> Locate
>>>>> With .pgfMainPageFrame.Page3
>>>>> With .grdJnyStage
>>>>> .Column1.chkCheck1.Value = IIF( JOURNEY = "Y", .T., .F.)
>>>>> .Column4.chkCheck1.Value = IIF( STAGE = "Y", .T., .F.)
>>>>> .Column7.chkCheck1.Value = IIF( MON = "Y", .T., .F.)
>>>>> ... tue, wed, thu, etc.
>>>>>...
>>>>>
>>>>>
>>>>>and, after edit, HOPE to save it as follows:
>>>>>
>>>>>
>>>>>If sysCONFIRM( "Save changes to Journey Stages Table?", ;
>>>>> "Confirm Save Changes")
>>>>> Select JNYSTAGE
>>>>> Locate
>>>>> If not RLOCK()
>>>>> = sysWARNINGMESSAGE( "Sorry. Unable to update the Journey Stages Table." + CHR(13) + ;
>>>>> "Another User has the table open for edit.", ;
>>>>> "Cannot Update Journey Stages")
>>>>> Else
>>>>> With this.Parent
>>>>> With .grdJnyStage
>>>>> Replace JOURNEY with IIF( .Column1.chkCheck1.Value, "Y", "N")
>>>>> Replace STAGE with IIF( .Column4.chkCheck1.Value, "Y", "N")
>>>>> Replace MON with IIF( .Column7.chkCheck1.Value, "Y", "N")
>>>>> ... tue, wed, thu, etc.
>>>>> .Refresh()
>>>>> EndWith
>>>>> = TABLEUPDATE( .T.)
>>>>> UNLOCK
>>>>> EndIf
>>>>>EndIf
>>>>>
>>>>>
>>>>>Trouble is: All recs in the grid get saved in the same permutation of checks as the 1st record and don't necessarily follow the underllying data. I've tried putting the Replaces in a scan-endscan, but what happened then was the children of the parent rec 3 got copied to those of parent rec 5, and removed from those of parent rec 3, and then only the top rec (out of 2 in this case).
>>>>>
>>>>>Now then, to predict the obvious questions:
>>>>>
>>>>>Each "checkbox" column has no .ControlSource (that just gives a data type m-m error anyway) and is not .Bound
>>>>>
>>>>>I'm probably missing something simple here (I'm not sure I've ever had to do this) - What can it be?
>>>>>
>>>>>'ppreciate it
>>>>>
>>>>>Terry
>>>>
>>>>You better bind columns, and use cursor for grid.recordsource. When cursor will get filled you may change 'datatype' for Y/N field, and you will make the opposite change on save point.
>>>
>>>Thanks, Ed.
>>>
>>>You mean, when saving, going through the cursor, in a scan, and doing a seek and replace on each matching dbf record?
>>>
>>>OK but I was hoping the grid and IIF()s could handle it more succinctly.
>>
>>If you bind a column to IIF() then it's readonly. If you don't bind a column then it cannot be used for data purposes. So, cursor is a good way, and it's your option to do Scan on save point or come up with Update command. Both ways are honorable.
>
>As I'm still using VFP7 I haven't (AFAIK!) got the flexibilty of issuing UPDATE with an SQL-select. So you mean the scan and seek-replace scenario?
>
>Thanks
Yes, you can do it.
Edward Pikman
Independent Consultant