Use Parameters Set in One DAP to Open Another
Problem
In Access, every report your users run starts with a dialog prompting them for input parameters, such as the requested timeframe for the report. How can you do the same thing with DAPs? You’d like the user to fill in start and end dates in the browser, and then open the page using those dates as a “where condition.”
Solution
There are several ways to handle this issue; we’ll show you two. Both solutions discussed here require that you base your DAP on a query that uses input parameters in the criteria. The first solution allows the DataSource control to do the work for you, much like allowing Access to display the Input Parameter dialog when you run a query that requires parameters. The second solution requires you to create another page that asks the user to enter the criteria, much like using a form to feed the query on which a report is based. This solution provides more flexibility but requires you to write some code in VBScript. The VBScript code uses cookies to pass information between the two pages.
The first solution requires no extra work on your part—it simply takes advantage of the DataSource component’s built-in functionality. To test it out with our sample database, follow these steps:
Open our sample query from
13-08.MDB
, qryOrdersByDate, in design view. The query is shown in Figure 13-23. Note the input parameters,[
Start
Date
]
and[
End
Date
]
, used as criteria.Figure 13-23. The data source for our pages ...
Get Access Cookbook now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.