Edit/Post an ADO Database

From: Merv Norton (mlnorton_at_cox.net)
Date: 08/19/04

  • Next message: Pontus Berg: "Re: Expert: Sorting a DBGrid from an Access Db via ADO"
    Date: Thu, 19 Aug 2004 14:54:29 -0400
    
    

    I have a Delphi 7 program that uses ADO and an ACCESS database. The Form
    contains eight sets of DBEdits for eight items that are for sale. They are
    Quantity , Cost and Shipping. I have an OnChangeEvent procedure for each of
    the eight sale items. A typical procedure is as follows:

    procedure TForm_Main.DBEdit_PoloLQtyChange(Sender: TObject);

    var

      Qty: integer;

      Cost1: Currency;

      Cost2: Currency;

    begin

      Qty := StrToInt(DBEdit_VietCapQty.Text);

      Cost1 := Qty * 13.00;

      Cost2 := Qty * 2.00;

      with ADOTable1 do

      begin

        edit;

        FieldByName('PoloLCost').AsString := CurrToStr(Cost1);

        FieldByName('PoloLSH').AsString := CurrToStr(Cost2);

        post;

      end;

    end;

    When I try to compile, I get an error on the third of these eight identical
    procedures. When the program attempts to compile the first FieldByName, I
    get an error that states that the program must be in Edit or Insert mode.

    I am in Edit mode and the first two of the eight procedures compiles with no
    problem.

    What is my problem and what is the solution


  • Next message: Pontus Berg: "Re: Expert: Sorting a DBGrid from an Access Db via ADO"