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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Keep ADOTable record selected after a chang to the record

Status
Not open for further replies.

MLNorton

Programmer
Nov 15, 2009
134
US
I have an ADOTable that contains 3,200 records of individuals that includes e-mail addresses. Only about half have valid e-mail addresses. I have a routine that deletes invalid e-mail addresses. It works. I search for the record that contains the Email that I want to delete. I do a cell click to extract the E-mail address that I want to delete. I the execute the following code to delete the selected E-mail:

procedure TForm_Listing.Button_DeleteClick(Sender: TObject);
begin
Form_Listing.ADOTable1.Edit;
Form_Listing.ADOTable1.FieldByName('Email').AsString := '';
Form_Listing.ADOTable1.Post;
end;
end;

The E-mail is deleted but the cursor jumps to another record. I need to keep the original record selected because I have another routine that reverses the process and replaces the deleted E-mail in in case I made a mistake. This routine is:

procedure TForm_Listing.Button_ReverseClick(Sender: TObject);
begin
Form_Listing.ADOTable1.Edit;
Form_Listing.ADOTable1.FieldByName('Email').AsString := Email;
Form_Listing.ADOTable1.Post;
end;

Since now a different record is selected, the E-mail address is entered in the new record.

How can I insure that the originally selected record remains selected after the successfully delete?
 
Does your table contain an index that includes the email field?

You can check out the TDataset.GetBookmark and TDataSet.GotoBookmark (and FreeBookmark) to help keep track of where you are.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top