You may want to create a class which contains the fields for each table that are autoincrement. Step through the class for the table and if any fields are excluded due to autoincrement, then exclude them in the gather statement as below:
store 'excludedfieldname' TO exfields
gather MEMVAR FIELDS EXCEPT &exfields
You can also use afields() and check for 'I' in the 2nd column and a value greater than 0 in 17 and 18.
(Not tested)
=AFIELDS(amyfields,'mytablealias')
exfields = ''
FOR i = 1 to ALEN(amyfields,1)
IF amyfields(i,2) = 'I' .and. amyfields(i,18) > 0
? amyfields(i,1)
? amyfields(i,2)
? amyfields(i,17)
? amyfields(i,18)
IF !EMPTY(exfields)
STORE exfields + ',' + amyfields(i,1) TO exfields
ELSE
STORE amyfields(i,1) TO exfields
ENDIF
ENDIF
ENDFOR
IF !EMPTY(exfields)
GATHER MEMVAR FIELDS EXCEPT &exfields
ELSE
GATHER MEMVAR
ENDIF
See afields() under VFP HELP.
>Hello to all
>
>I am having a very sporadic problem. I have a table with an autoIncrement primary key named INVTYPEPK. On occasion,
>The error:
>
> "Field INVTYPEPK is read only”
>
>The code:
>
> GATHER MEMVAR MEMO && FIELDS EXCEPT invTypePK
>
>We have granted full-rights to the user, but the error still occurs sporadically. It has yet to occur with any other users, but the routine is used rarely by others.
>
>Any ideas??
>
>Thanks in advance
.·*´¨)
.·`TCH
(..·*
010000110101001101101000011000010111001001110000010011110111001001000010011101010111001101110100
"When the debate is lost, slander becomes the tool of the loser." - Socrates
Vita contingit, Vive cum eo. (Life Happens, Live With it.)
"Life is not measured by the number of breaths we take, but by the moments that take our breath away." -- author unknown
"De omnibus dubitandum"