ACC2000: WITH CHECK OPTION Clause Is Not Enforced Within a View (213844)
The information in this article applies to:
This article was previously published under Q213844 This article applies only to a Microsoft Access project (.adp).
Advanced: Requires expert coding, interoperability, and multiuser skills.
SYMPTOMS
You can add new data to or you can modify existing data within a view even though the view implements WITH CHECK OPTION. Although you may receive the following Microsoft Access error when you save the new or modified record, the record is still saved, and the record is then removed from Datasheet view:
The data was added to the database but the data won't be displayed in the form because it doesn't satisfy the criteria in the underlying record source.
RESOLUTION
Use a stored procedure to add or update data within the view, where the view enforces WITH CHECK OPTION. For an example of how to do this, follow these steps:
- Open the sample Access project NorthwindCS.adp.
- Press CRTL+G to open the Immediate window.
- Type in the following statement to create the view:
CurrentProject.Connection.Execute _
"CREATE VIEW vwCheckOp2 AS SELECT ProductID, ProductName, UnitPrice FROM Products WHERE UnitPrice > 15 WITH CHECK OPTION", _
False,False
- Use the following syntax to create a new stored procedure:
Create Procedure spCheckOp
As
UPDATE vwCheckOp2
SET UnitPrice = 12
WHERE ProductID = 1
- Execute the stored procedure after you have closed and saved the procedure. Note that you receive the following message when you run the procedure, and that you cannot update the record:
The attempted insert or update failed because the target view either specifies WITH CHECK OPTION or spans a view that specifies WITH CHECK OPTION and one or more rows resulting from the operation did not qualify under the CHECK OPTION constraint.
REFERENCESFor additional information, click the article number below
to view the article in the Microsoft Knowledge Base:
198105 BUG: Errors When Creating a View Using the WITH CHECK OPTION in SQL Enterprise Manager
Modification Type: | Major | Last Reviewed: | 6/29/2004 |
---|
Keywords: | kbprb KB213844 |
---|
|