Simplest way is to use the "Command Button Wizard", which will activate when you click on the button icon of the toolbox. When you've got the form that you are designing open, then:
(a) Ensure that you have the toolbox exposed. If not, make it visible via the View, Toolbox menu options.
(b) On the toolbox, ensure that the "Control Wizards" wand is hilited. If not click on it.
Then, click on the Command Button icon in the toolbox, place the button on the form, select the "Record Operations" category, and the "Delete Record" action. Click on Next, then select how you want the button to display, and click finish.
Thats pretty well it. If you're feeling brave, you can inspect the code which is generated behind the button.
Steve is pointing you in the right direction if you REALLY want to delete the record.
As a general rule, I set up tables with an IsActive Yes/No field. If the user wants to delete records, I add a command button that simply sets the IsActive value to No. All queries used to display/report active records are set to select only records where the IsActive value is Yes.
I will also include a maintenace feature that will copy the 'Deleted' records to a separate storage table and then actually delete them from the main table.
Too often, users really do not want to delete records just not see them as active.
Hope this helps. Larry De Laruelle
ldelaruelle@familychildrenscenter.org
I finally know the function of the "Control Wizards", I have created a delete button but I can't delete my record.
It shows a message box state that "The record cannot bee deleted or changed Because table 'Part (Fixed)' includes related records." Is it means that I gotta delete all the related records before I can delete this particular record? Any simple way? 'Part (Fixed)' is 1 of my tables. I want to delete 1 of the record in this table when I onclick the delete button. Can it be done?
Larry makes some valid points about whether you really wish to delete, as opposed to "de-activate" these records.
Keep this in mind.
Notwithstanding this, it sounds like you have "referencial integrity" set between (some of) the tables in your database. Suggest you read up about this in the online help. Basically it prevents you from deleting records in one table, if related records exist in another (eg. if you have a table called tblInvoices, and another called tblInvoiceLineItems, then it will prevent you from deleting an Invoice header record as long as related record(s) exist of associated Invoice Line items.
To check up on this and remove the RI, or set up "cascading deletions", do the following:
(a) From the database window, right click, and select the Relationships option.
(b) This should display any relationships that have been set up between the tables in the database. If the screen is blank, try selecting the Relationships, Show All options"
(c) The table from which you are trying to delete records from, is probably connected via a relationship line, to one or more other tables. For each of these relationship lines:
(d) Double click on it. I would anticipate that the "Enforce Referencial Integrity" option is set on at least one of these relationships. Where this is the case, toggle on the "Cascade Delete Related Records" option.
(e) Do the above step for each table which is related to the table from which you are attempting to delete the records from.
When this is done, Save and exit the relationships screen. Your delete button should now work, but bear in mind that it will be deleting any associated "child" records as well as the parent record. You may get a warning message about this depending on your option settings.
With all of this, I'm assuming that your tables are held in the same database as the Form that you are working on. If not, you will have to identify the database in which the tables are held, and perform the Relationship changes described above in this database.
You listed out a good point. It works!
Thank you very much.
I forgot to set the "Cascade Delete Related Records" option and that hold back the whole program.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.