So the Form data is
Dataset Identifier = Order Column Identifier = Customer onchange = pFillFrom end End
The idea is to fill the adress fields from Order with that of the adress information from Customer, when a customer is selected by its number, in said form. This with one procedure.
procedure pFillFrom; var qry: TCQuery; begin qry := CreateQry('select C.housenumber housenr, C.place place, C.areacode areacode, C.street street, O.customer, O.from_street fromStreet, O.from_houseNr fromHousenr, O.from_areacode fromAreacode, O.fromPlace fromPlace'); qry.SQL.add('from Customer C, Order O'); qry.SQL.add('where O.Customer = C.nr and O.Customer =: k'); qry.ParamByName('k').AsInteger := FieldByName('customer').AsInteger; qry.Execute; qry['housenr'].AsString := qry['fromHousenr'].AsString; qry['place'].AsString := qry['fromPlace'].AsString; qry['areacode'].AsString := qry['fromAreacode'].AsString; qry['street'].AsString := qry['fromStreet'].AsString; end;
The error i receive is :
Unknown Identifier : FieldByName
But the procedure is to be executed in Order, which has a fieldname Customer ... so...
If i change it to Order.FieldByName('customer').AsInteger it says it doesn't recognize Order.
Im at a loss here, any help is appreciated.
The other procedure is a calculator:
Calculating the price of an order that is.
procedure pCalcPrice; var annuled: string; qry:TcQuery; begin if (annuled= 'Y') then qry := CreateQry('update Order set amount = '); qry.SQL.add('select annul_cost from System S'); else begin qry : = CreateQry('update Order set amount = '); qry.SQL.add('select G.addedRate, G.weight, G.cost_per_kilo, S.start_cost from Order O, WeightGroup G, System S, '); qry.SQL.add('where G.nr = O.weightgroup'); qry.SQL.add('where nr = :nr'); qry.ParamByName('nr').AsInteger := FieldByName('nr').AsInteger; qry.ParamByName('amount').AsFloat := Order.FieldByName('amount').AsFloat; qry.Execute; FieldByName('amount').AsFloat := qry.FieldByName('S.start_cost').AsFloat + qry.FieldByName('G.addedRate').AsFloat - (qry.FieldByName('G.weight').AsFloat * qry.FieldByName('G.cost_per_kilo').AsFloat); end ; end;
System S is a singleton.
The first error it gives is that it expects an identifier around the else statement. But i can't see where and what exactly.
This post has been edited by Random01: 02 December 2013 - 11:08 AM