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

dbedit

Status
Not open for further replies.

domkop

Programmer
Joined
Aug 19, 2003
Messages
22
Location
NL
i never used databases now i am trying but got some problems.
i.ve got a dbedit field that is a required field and must be a unique value.
i get errors if the field is empty or not unique, how can i check this, does anyone has an example.
i am usingdelphi 7 and an paradox table.

domkop
 
There are a couple of places where you can check this. The one I would use is the OnExit event of the dbEdit. The code would look something like this:
Code:
procedure TMyForm.dbEdit1Exit(Sender: TObject);
begin
  if (dbEdit1.Text = '') and (Sender <> btnCancel) then
  begin //don't do the check if the user clicked on the cancel button
    ShowMessage('This field must have a value');
    dbEdit1.SetFocus;  //put the cursor back in the dbEdit
  end;
end;

You can also use the OnValidate event of the field which will fire before the record is posted.

-Dell

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top