if (`$val`==1)
  {
     $CaseId=$_SESSION[`CaseId`];
     $ProjectId=$_SESSION[`ProjectId`];
     ExecuteSQL("insert into Responses (CaseID,qID,ProjectId) select $CaseId, `Q_Loop1_1`, $ProjectId");
     $rInstance=ShowQueryResultScalar("select max(rUnique) from Responses where qID=`Q_Loop1_1` and ProjectId=$ProjectId");
     ExecuteSQL("update Responses set rInstance=$rInstance where rUnique=$rInstance");
     $_SESSION[`Instance`]=$rInstance;
  }
$stat=1;