programming4us
 
Office
 

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

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
 
 
REVIEW
 
- First look: Apple Watch

- 10 Amazing Tools You Should Be Using with Dropbox

- Sigma 24mm f/1.4 DG HSM Art

- Canon EF11-24mm f/4L USM

- Creative Sound Blaster Roar 2

- Alienware 17 - Dell's Alienware laptops

- Smartwatch : Wellograph

- Xiaomi Redmi 2
 
VIDEO TUTORIAL
 
- How to create your first Swimlane Diagram or Cross-Functional Flowchart Diagram by using Microsoft Visio 2010 (Part 1)

- How to create your first Swimlane Diagram or Cross-Functional Flowchart Diagram by using Microsoft Visio 2010 (Part 2)

- How to create your first Swimlane Diagram or Cross-Functional Flowchart Diagram by using Microsoft Visio 2010 (Part 3)
 
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
 
Top 10
 
- How To Install Android Market & Google Apps On Kindle Fire
- How To Make Ubuntu Look Like Windows 7
- How To Add A New Account in MS Outlook 2013
- Get Android & Mac OS X Style Gadgets For Windows 7 & Windows 8 With XWidget
- How To Activate Microsoft Office 2013
- How To Install Actual Facebook App On Kindle Fire
- How To Create, View And Edit Microsoft Office Files On Kindle Fire
- Download Attractive Business PowerPoint Templates For Free At SlideHunter
- How To Use And Enable Hibernate & Sleep Mode In Windows 8
- How To Get Microsoft Office 2013 Trial Product Key From Microsoft