I have a SQL Server backend and use SPT to create buffered local cursors (bit shakey on some of the terminology there, but I think that's about right). When adding a new record I use: APPEND BLANK and this works fine. I can then use either TABLEUPDATE() or TABLEREVERT() to update the backend or not. Again, this works fine.
The problem I have is that when I create a new record the default values (when updated to the server) are <NULL>. Not a problem for fields that the user changes, but a blank checkbox can often stay blank, so the user doesn't touch it. But when the record is retrieved later the checkbox shows NULL (shaded). I found some code somewhere that attempts to loop through all the fields in the new record and kind of initialise them according to their datatype:
I guess the idea being that then the user can, say leave a checkbox off and the SQL database will result in a 0, rather than a <NULL>. The above doesn't work (fields still show up null). Is there a better way of dealing with this?
Tom
The problem I have is that when I create a new record the default values (when updated to the server) are <NULL>. Not a problem for fields that the user changes, but a blank checkbox can often stay blank, so the user doesn't touch it. But when the record is retrieved later the checkbox shows NULL (shaded). I found some code somewhere that attempts to loop through all the fields in the new record and kind of initialise them according to their datatype:
Code:
FOR i = 1 TO FCOUNT(ALIAS())
fldType = VARTYPE(EVALUATE(FIELD(i)))
DO case
CASE fldType = 'C' && Character field set to empty string
fld = FIELD(i)
&fld = ''
CASE fldType = 'L' && Logical field set to false
fld = FIELD(i)
&fld = .F.
ENDCASE
NEXT
Tom