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

Cancelling Table scroll

Status
Not open for further replies.

Fleabit

Programmer
Nov 16, 2002
14
US
I want to check the data in a record appearing in an editable DBGrid to make sure all the data is valid before the Table scrolls to a new record. Writing the data checking code in the Table's BeforeScroll event seems like the logical place to perform this function, but is there a way to abort the scroll to another record if the data in the current record is invalid and force the user to correct the data?
 
I usually do this:
I'm using TQuery or TADOQuery as Dataset.
I do some checking on BeforePost event of the dataset, like this:

Code:
procedure TForm1.Query1BeforePost(DataSet: TDataSet);
begin
  If Query1Field1.IsNull then
  begin
    MessageDlg('Field1 must be defined', 
      mtInformation, [mbOk], 0);
    Abort; //dataset.post action will be aborted
  end;
end

If you put it on BeforeScroll event, the event will be executed everytime you navigate to another record.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top