| ||||||||||||
|
|
Choose Function ExampleChoose function in MS Access: Have you ever had to create several reports that were almost
identical but had different order for the columns and a different sort
order?
Many of these reports can be done in one intelligent
report and query combination with the Access Command: Choose function.
Both combo boxes have the same Row Source. Note that there are two columns in the row source; the first is a number (1, 2) and the second is the name of the field to be included in the report and sorted by.
The choose code looks like this:
Note that we will always retrieve the employee's Pay_Rate field, however this could be variable as well. You'll also need to see the example code for the query to see how the Order By clause works for this Access choose command example: SELECT Here's the resulting report using the choose function:
The second trick is how I got the column headings to come out correctly... All that's required is one line of VBA code for each label.. but before I show that here is the design view of the report:>
Ok, let's see how the VBA code assigns the correct values to the labels: Option Compare Database Using the Access Choose function query can be extended to numerous fields and could probably be used for aggregate functions too, but I haven't tried that yet. The alternative to using the Access Choose command is to write many lines of VBA code in the report or behind the parameter form (Form1). You can also use the choose function to pass parameters to an Access Query. |
We now offer web-based SQL/Server application development in partnership with Integrated Databases, Inc. (new projects only). |
|
|