Views have never in the past been able to contain parameters; however, as shown later in the chapter, user-defined functions can now be used like views, effectively allowing you to create parameterized views that return different results depending on the parameter values that get passed in each time the function is run.Unlike stored procedures (which also support parameters), these parameterized functions can be updateable, as you'll see later in this chapter.You may already have discovered that you can often greatly speed up Access reports by first saving the results of a complex record source query into a temporary table and then basing the report on that table rather than on the query. Row-level security must be defined at runtime because it's impossible to know what values a table will contain until then.

So, a view that returns the top 100% by sales would essentially be a sorted view.

The triggers in views are covered later in this chapter.

To restrict the rows in a view, you use the same kinds of criteria in a clause. This happens when the view and the underlying table do not have the same owner.

For example, the following view limits the result set by selecting only the employee first name, last name, and hire date columns from the Employees table, and it limits the rows returned to employees hired this year: One of the most powerful uses of views is for reporting. When the chain of ownership is broken, you need to grant users the same permissions on the underlying tables as you want them to have on the view, which nullifies the effectiveness of views as security mechanisms.

A view can be used to wrap up complex queries containing subqueries, outer joins, and aggregation. Another problem you'll encounter with Access projects (ADPs) is that if you want users to be able to update data using a view, you also have to grant them permissions on the underlying tables.

This simplifies access to the data because the underlying query does not have to be written on the client and then submitted each time a report is run. Although you can set column-level security in SQL Server, it is tricky to maintain because it's pretty well buried in the table properties.

The information about where the data in a view comes from and how it is pulled together from various tables is all encapsulated inside the view. Here are some general guidelines for creating views: Views are frequently used as security mechanisms to prevent users from having direct access to tables while still allowing them to work with data.

Tables can be customized and tailored to the needs of the users by way of views. All permissions can be removed from the underlying tables, and as long as the owner of the table is the same as the owner of the view, the user will be able to interact with the data based on the permissions granted to the view.

The primary use of views is to present data to users of an application.

Views can be used in place of tables in your Access front-end application, whether you're using an Access database or an Access project.

For example, the following view selects a customer's total orders and contains joins between the Customers table, the Orders table, and the Order Details table. Instead, define views with only selected columns to implement column-level security and define views with a clause to implement row-level security.