Results 1 to 2 of 2
Thread: Deleting an order (Access 2000)
2002-05-11, 10:25 #1
- Join Date
- Feb 2002
- Thanked 0 Times in 0 Posts
Deleting an order (Access 2000)
I have a form with a control called OrderId.I want to have a delete command in the OnClick event of the control OrderID deleting the whole order I tried the following code:
Delete* FROM "Orders", WHERE orders.orderid = " & Screen.ActiveControl.Value
But Acces does not acept my code.
It is a difficult task for me becasue ususally the order does not contain only one product, that is to say one record, and also the order
is tied up with the table "order details" where i store the additional information.
My form is built as a Tabular form, not Columnar.Can i delete the entire order, together with its related information just with one click?
I have connected my tables with a cascade referential integrity,so i hope that deleting the order i may delete also the corresoponding order in the table order
details but who knows?
I suspect this problem may be too easy for an profesional,but it is too hard for me to solve.
May i have some help?
2002-05-11, 13:17 #2
- Join Date
- Jun 2001
- Crystal Beach, FL, Florida, USA
- Thanked 36 Times in 35 Posts
Re: Deleting an order (Access 2000)
First of all, you SQL code probably won't work because of the comma before the WHERE clause.
But beyond that, I have a real problem with deleting a record merely because the use clicked on it! Instead, you can do one of 2 things. Make sure that your form's RecordSelectors are active. Then a user can click on the RecordSelector and then hit the Delete key. Or, just add a command button to the form with this line of code in its Click event:
If you have enforced referential integrity between your Orders table and the Details table, and if you have Cascaded Deletes, then the Detail records will also be automatically deleted.