IT tutorials
 
Office
 

Microsoft Accesss 2010 : Enhancing the Queries That You Build - Creating and Running Action Queries (part 2) - Creating and Running Delete Queries

- How To Install Windows Server 2012 On VirtualBox
- How To Bypass Torrent Connection Blocking By Your ISP
- How To Install Actual Facebook App On Kindle Fire
11/16/2014 8:02:55 PM

Creating and Running Delete Queries

Rather than just modify table data, Delete queries permanently remove from a table any records that meet specific criteria; they’re often used to remove old records. You might want to use a Delete query to delete all orders from the previous year, for example.

It’s important to remember that if you have turned on the Cascade Update Related Fields Referential Integrity setting and the Update query tries to modify a primary key field, Access updates the foreign key of each corresponding record in related tables. If you have not turned on the Cascade Update Related Fields setting and you have enforced referential integrity, the Update query doesn’t allow you to modify the offending records.


Build a Delete Query

To build a Delete query, follow these steps:

1.
While in a query’s Design view, select Delete from the Query Type group on the Design tab of the Ribbon.

2.
Add to the query grid the criteria you want. The query shown in Figure 3 deletes all orders with a Status ID of 3 (closed).

Figure 3. A Delete query that is used to delete all time cards entered more than a year ago.

3.
Click Run in the Results group on the Design tab of the Ribbon. The message box shown in Figure 4 appears.

Figure 4. The Delete query confirmation message box.


4.
Click Yes to permanently remove the records from the table.

The SQL behind a Delete query looks like this:

DELETE tblTimeCards.DateEntered
FROM tblTimeCards
WHERE (((tblTimeCards.DateEntered)<Date()-365));

It’s often useful to view the results of an Action query before you actually affect the records included in the criteria. To view the records affected by an Action query, you click the View button in the Results group on the Design tab of the Ribbon before you select Run. All records that will be affected by the Action query appear in Datasheet view. If necessary, you can temporarily add key fields to the query to get more information about the records that are about to be affected.


Remember that if you turn on the Cascade Delete Related Records Referential Integrity setting, Access deletes all corresponding records in related tables. If you do not turn on the Cascade Delete Related Records setting and you do enforce referential integrity, the Delete query doesn’t allow you to delete the offending records. If you want to delete the records on the “one” side of the relationship, first you need to delete all the related records on the “many” side.

 
Others
 
- Microsoft Accesss 2010 : Enhancing the Queries That You Build - Creating and Running Action Queries (part 1) - Creating and Running Update Queries
- Microsoft Accesss 2010 : Enhancing the Queries That You Build - Creating and Running Parameter Queries
- Microsoft Accesss 2010 : Enhancing the Queries That You Build - Getting Help from the Expression Builder
- Microsoft Accesss 2010 : Enhancing the Queries That You Build - Creating Calculated Fields
- Using OneNote with Other Office 2010 Applications : Entering Outlook Information (Email, Meeting, Contact, Task) on a Page
- Using OneNote with Other Office 2010 Applications : Entering Meeting Details from Outlook in a Note
- Using OneNote with Other Office 2010 Applications : Opening a Page in Word, Creating an Outlook Task in OneNote
- Microsoft Visio 2013 : A Visual Orientation to a Visual Product - Panning and zooming in Visio
- Microsoft Visio 2013 : A Visual Orientation to a Visual Product - Managing the Shapes window
- Microsoft Visio 2013 : A Visual Orientation to a Visual Product - Exploring the drawing window
 
25 Inspiring Game of Thrones Quotes
 
Top 10
 
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 2) - Wireframes,Legends
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 1) - Swimlanes
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Formatting and sizing lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Adding shapes to lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Sizing containers
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 3) - The Other Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 2) - The Data Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 1) - The Format Properties of a Control
- Microsoft Access 2010 : Form Properties and Why Should You Use Them - Working with the Properties Window
- Microsoft Visio 2013 : Using the Organization Chart Wizard with new data
programming4us programming4us
 
Popular tags
 
Video Tutorail Microsoft Access Microsoft Excel Microsoft OneNote Microsoft PowerPoint Microsoft Project Microsoft Visio Microsoft Word Active Directory Biztalk Exchange Server Microsoft LynC Server Microsoft Dynamic Sharepoint Sql Server Windows Server 2008 Windows Server 2012 Windows 7 Windows 8 Adobe Indesign Adobe Flash Professional Dreamweaver Adobe Illustrator Adobe After Effects Adobe Photoshop Adobe Fireworks Adobe Flash Catalyst Corel Painter X CorelDRAW X5 CorelDraw 10 QuarkXPress 8 windows Phone 7 windows Phone 8 BlackBerry Android Ipad Iphone iOS