Hey guys i have an application where i assign values to the type of sale it would be -- here's my code --
procedure TPaymentForm.OkButtonClick(Sender: TObject);
begin
//ID 1 - Cash Sale
IF (CashRadioButton.Checked) Then
BEGIN //Opening Data Source and Stuff, Setting The Columns and Stuff
Data.Statement_Entries_Table.Append;
Data.Statement_Entries_Table.FieldByName('customer_id').AsInteger;
Data.Statement_Entries_Table.FieldByName('date_time').AsDateTime := Now;
Data.Statement_Entries_Table.FieldByName('description').AsString;
Data.Statement_Entries_Table.FieldByName('amnount').AsCurrency := TxtAmount.Value;
Data.Statement_Entries_Table.FieldByName('entrytype').AsInteger := 1;
Data.Statement_Entries_Table.FieldByName('entry_ref').AsInteger;
Data.Statement_Entries_Table.Post;
END;
//ID 2 - Cedit Sale
IF (CreditRadioButton.Checked) Then
BEGIN //Opening Data Source and Stuff, Setting The Columns and Stuff
Data.Statement_Entries_Table.Append;
Data.Statement_Entries_Table.FieldByName('customer_id').AsInteger;
Data.Statement_Entries_Table.FieldByName('date_time').AsDateTime := Now;
Data.Statement_Entries_Table.FieldByName('description').AsString;
Data.Statement_Entries_Table.FieldByName('amnount').AsCurrency := TxtAmount.Value;
Data.Statement_Entries_Table.FieldByName('entrytype').AsInteger := 2;
Data.Statement_Entries_Table.FieldByName('entry_ref').AsInteger;
Data.Statement_Entries_Table.Post;
END;
//ID 3 - Internetsale
IF (InetrnetTransferRadioButton.Checked) Then
BEGIN //Opening Data Source and Stuff, Setting The Columns and Stuff
Data.Statement_Entries_Table.Append;
Data.Statement_Entries_Table.FieldByName('customer_id').AsInteger;
Data.Statement_Entries_Table.FieldByName('date_time').AsDateTime := Now;
Data.Statement_Entries_Table.FieldByName('description').AsString;
Data.Statement_Entries_Table.FieldByName('amnount').AsCurrency := TxtAmount.Value;
Data.Statement_Entries_Table.FieldByName('entrytype').AsInteger := 3;
Data.Statement_Entries_Table.FieldByName('entry_ref').AsInteger;
Data.Statement_Entries_Table.Post;
END;
//ID 4 - Cheque sale
IF (ChequeRadioButton.Checked) Then
BEGIN //Opening Data Source and Stuff, Setting The Columns and Stuff
Data.Statement_Entries_Table.Append;
Data.Statement_Entries_Table.FieldByName('customer_id').AsInteger;
Data.Statement_Entries_Table.FieldByName('date_time').AsDateTime := Now;
Data.Statement_Entries_Table.FieldByName('description').AsString;
Data.Statement_Entries_Table.FieldByName('amnount').AsCurrency := TxtAmount.Value;
Data.Statement_Entries_Table.FieldByName('entrytype').AsInteger := 4;
Data.Statement_Entries_Table.FieldByName('entry_ref').AsInteger;
Data.Statement_Entries_Table.Post;
END;
CashRadioButton.Checked := False;
CreditRadioButton.Checked := False;
InetrnetTransferRadioButton.Checked := False;
ChequeRadioButton.Checked := False;
TxtAmount.Text := '';
Close;
end;
I have a text box for entering an amount into the data, and 4 radio butttons or option buttons whatever for choosing an option of payment...
Every time i click on the ok button the entry is stored in the first row of the Datatable and overrides the original one....
i am using MS Office access as database...
Please help...