I'm using an ADO with my computing project but there is one section within the code that won't allow me to run it.
[cpp]Procedure TInvoice.saveInvoice; // Error appears in the section
var
customerid : integer;
begin
if not ADOInvoices.Locate('InvoiceID',tbxInvoiceNo.text, []) then
begin
ADOInvoices.Edit; // Allows data to be saved
// Used for debugging - finds customerid
ShowMessage(ADOCustomers.Lookup('CustomerName', tbxCustomers.text, 'CustomerID'));
customerid:=StrToInt(ADOCustomers.Lookup('CustomerName', tbxCustomers.text, 'CustomerID'));
ADOInvoices['CustomerID']:=customerid;
ADOInvoices['InvoiceDate']:=tbxDate.date;
ADOInvoices['InvoiceTotal']:=StrToCurr(tbxTotal.text);
ADOInvoices.post;
end
else
ShowMessage('Invoice already exists');
end;[/cpp]
The program crashes with an error "Dataset not in edit or insert mode" at the line:
ADOInvoices['CustomerID']:=customerid
Can anybody work out why the program is crashing at this point?
[editline]4th February 2011[/editline]
Ignore this, after a solid day looking at it and getting nowhere, seconds after posting this I fixed it.
Sorry, you need to Log In to post a reply to this thread.