Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 5 of 5 total
Thread what's wrong in this
Mon, Apr 17 2006 4:47 PMPermanent Link

Khaled Homouda
If MeFreezeId.Text <> '' then begin
    with IvfData.TbEgg do begin
    Try
      TempCycleId := CycleId ;
      MasterSource := nil ;
      IndexName := 'CryoIdx' ;
      Filter := '(CycleId = '+MeFreezeId.Text+') AND (Cryoed = True)' ;
      Filtered := True ;
      if not active then open ;
      CopyTable('Remoteobgyn', 'TempEgg') ;
      Filtered := False ;
      if not TempEgg.active then TempEgg.open ;
      TempEgg.First ;
      IvfData.TbEgg.insert ; // after this, table stays in browse mode !!!
      For i:=0 to TempEgg.RecordCount-1 do
        begin
          For j := 0 to TempEgg.FieldCount - 1 do //FieldCount gives access Violation in debug inspector
          begin
             If not (TempEgg.Fields[j].FieldName = 'CycleId') then
             IvfData.TbEgg.Fields[j].Value := TempEgg.Fields[j].Value //gives access violation
             else IvfData.TbEgg.Fields[j].Value := TempCycleId ;
          end ;
          IvfData.TbEgg.post ;
          TempEgg.next ;
        end ;
      Finally
       TempEgg.Close ;
       TempEgg.DeleteTable ;
       MasterSource := IvfData.DsCycle ;
       IndexName := 'InCycleId' ;
       TsLab.TabVisible := True ;
      end ;
    end ;
  end else ShowMessage('Please enter a previous cycle id');
Mon, Apr 17 2006 5:30 PMPermanent Link

Sean McCall
Khaled,


IvfData.TbEgg.insert ;
// do you have any event handlers attached to this table?
// is the table read only (don't know if read only would
// generate an error or just ignore the insert. Probably the
// former.
>        For i:=0 to TempEgg.RecordCount-1 do
// I would use: while not(TempEgg.EOF) do
>            For j := 0 to TempEgg.FieldCount - 1 do
// FieldCount gives access Violation in debug inspector
// Are you sure that TempEgg was properly initialized and
// was not freed somewhere else? There
// should only be an access violation if TempEgg is not a
// valid instance of a TDataset descendant.
>            begin
>               If not (TempEgg.Fields[j].FieldName =
'CycleId') then
>               IvfData.TbEgg.Fields[j].Value :=
TempEgg.Fields[j].Value //gives access violation
// try IvfData.TbEgg.Fields[j].Assign (TempEgg.Fields[j]);
// this is cleaner, but both assume identical field order
// and field count in both tables.

HTH,

Sean

Khaled Homouda wrote:
> If MeFreezeId.Text <> '' then begin
>      with IvfData.TbEgg do begin
>      Try
>        TempCycleId := CycleId ;
>        MasterSource := nil ;
>        IndexName := 'CryoIdx' ;
>        Filter := '(CycleId = '+MeFreezeId.Text+') AND (Cryoed = True)' ;
>        Filtered := True ;
>        if not active then open ;
>        CopyTable('Remoteobgyn', 'TempEgg') ;
>        Filtered := False ;
>        if not TempEgg.active then TempEgg.open ;
>        TempEgg.First ;
>        IvfData.TbEgg.insert ; // after this, table stays in browse mode !!!
>        For i:=0 to TempEgg.RecordCount-1 do
>          begin
>            For j := 0 to TempEgg.FieldCount - 1 do //FieldCount gives access Violation in debug inspector
>            begin
>               If not (TempEgg.Fields[j].FieldName = 'CycleId') then
>               IvfData.TbEgg.Fields[j].Value := TempEgg.Fields[j].Value //gives access violation
>               else IvfData.TbEgg.Fields[j].Value := TempCycleId ;
>            end ;
>            IvfData.TbEgg.post ;
>            TempEgg.next ;
>          end ;
>        Finally
>         TempEgg.Close ;
>         TempEgg.DeleteTable ;
>         MasterSource := IvfData.DsCycle ;
>         IndexName := 'InCycleId' ;
>         TsLab.TabVisible := True ;
>        end ;
>      end ;
>    end else ShowMessage('Please enter a previous cycle id');
>
Tue, Apr 18 2006 3:36 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Khaled


My guess would be as Sean said - an event handler, but it could also be the table is used for a lookup and that's causing the cursor to move.
Roy Lambert
Tue, Apr 18 2006 12:20 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Khaled,

Sean is correct - something like an event handler is causing the record
pointer to move and take the dataset out of insert mode and back into browse
mode.  Check all lookup fields, calculated fields, and event handlers to
ensure that this isn't the case.

--
Tim Young
Elevate Software
www.elevatesoft.com

Mon, Apr 24 2006 4:56 PMPermanent Link

Khaled Homouda
thanks all, ypou are right it was onNewRecord it was an an incrementing routine, thanks all

Image