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!

ADOTableControls.Edit;

Status
Not open for further replies.

Mezzzo

Technical User
May 30, 2003
56
US
I`m attempting to add data to a access table. When I click
suiButton2 all the data in the dbedtboxes disappears. That
wasn`t what I wanted. How do I correct this problem
Also, How would I setup this code to add a new set of data
to the table each time the button is clicked. As it is if
I enter new data it overwrites the exsisting data but does
not add a new row.
PS.Thanks for you help.....greatly appreciated.

procedure TfrmDrw.suiButton2Click(Sender: TObject);
begin
if not (ADOTableControls.State in [dsInsert, dsEdit]) then
ADOTableControls.Edit;
with ADOTableControls do begin
Insert;
FieldByName('MatSolidSpecies').Value := dbcboSpecSolid.Text;
FieldByName('MatSolidRoughThk').Value := dbedtRghThkSolid.Text;
FieldByName('MatSolidFinishThk').Value := dbedtFinThickSolid.Text;
Post;
end;

end;

end.
 
hi

Try changing the edit to Insert

if not (ADOTableControls.State in [dsInsert, dsEdit]) then
ADOTableControls.Insert;

About your first question, what may be happening is if the ADOTableControls is not in Insert or Edit mode, the code is going on to do an insert in any case and the .Texts are
probably blank.

...maybe you need something like this

procedure TfrmDrw.suiButton2Click(Sender: TObject);
begin
if not (ADOTableControls.State in [dsInsert]) then
ADOTableControls.Insert;
with ADOTableControls do begin
FieldByName('MatSolidSpecies').Value := dbcboSpecSolid.Text;
FieldByName('MatSolidRoughThk').Value := dbedtRghThkSolid.Text;
FieldByName('MatSolidFinishThk').Value := dbedtFinThickSolid.Text;
Post;
end;


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top