Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error:Dataset not in edit or insert mode 1

Status
Not open for further replies.

pkakkar

Programmer
Apr 24, 2008
15
0
0
FI
Hello,

I have a form with DBGrid which has 3 buttons insert, edit and delete..If I click on delete Form3 opens up and all the corresponding values are displayed in edit boxes.It asks me if I want to delete this record. If I press 'Yes' button. It deletes the record (code written below)

procedure TForm3.Button1Click(Sender: TObject);
var
begin
close;
Form1.DBGrid1.DataSource.DataSet.Edit;
Form1.DBGrid1.DataSource.DataSet.Delete;
Form1.DBGrid1.DataSource.DataSet.Next;
Form1.DBGrid1.DataSource.DataSet.Post;
end;

It actually deletes the record but gives me error message also that 'MSQuery1:Dataset not in edit or insert mode'. Can someone pls suggest where is the problem.

Regards
Pooja
 
what the ????????

if the dataset is in edit mode you cant delete.
if the dataset isnt in edit or append mode you cant post.

to delete its Form1.DBGrid1.DataSource.DataSet.Delete;

you edit to make changes then you post.
you append or insert to add a record then you post.

btw you can access the table on the form directly you dont have to do it via the grid.

Form1.mytable.delete;

Aaron
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top