PDA

View Full Version : A button to delete records using vba



wedd
12-18-2010, 10:44 AM
Hi, I would like to be able to delete records of my customers on a form that i developed by clicking on a button. Do you know of or have a sample of vba code i can use to do this operation?

Thanks for your contributions! :friends:

orange
12-18-2010, 03:22 PM
Instead of deleting the record, you may want to have a delete_flag field on the Customer table. Set this flag to "Y" to indicate this Customer has been deleted.

Use the delete_flag value in any queries/forms and reports to account for deleted Customers.
eg
To Select active/current Customers:


Select * from Customer where delete_flag <> "Y"

To Delete a Customer:
Use an Update query to set the delete_flag.


UPDATE Customer SET delete_flag = "Y"
WHERE Customer_ID = ...the value of Customer_ID based on your form

air code --- not tested