select MyData llNewRec = (chrtran(getfldstate(-1),"34","")=="") tableupdate(...) if llNewRec nHandle = cursorgetprop("ConnectHandle","MyData") =SQLEXEC(nHandle, "SELECT @@IDENTITY as nID","MyCursor") if used("MyCursor") AND !IsNull(MyCursor.nID) replace MyData.nID with MyCursor.nID select MyData tableupdate(...) && update it again, but make nID field not updatable. This will not generate real &&update to SQL Server, but it is needed just to store nID in the cursor and mark it as it && is not changed. SetFldState() function do nto works in this place. endif if used("MyCursor") use in MyCursor endif endifHTH.