| ||||||||||||
|
|
Choose Command in Microsoft AccessThe choose command is similar to the Decode function in
Oracle. Assume the same setup as the
Dynamic Order
By Clause example but add a 3rd option for sorting by Address.
See below how the choose function expands your capabilities. Note: Entry in Forms!F_Emp!Sort_Option must be an integer and it is best to force it to a number with the Val() function. You can have up to 29 options and you can use the Choose Function in each part of the query except the From clause.
The choose function can be used in each part of a query, except possible the From clause. 2nd Choose Example My boss wants an employee salary report and on odd days of the month he wants the data to show by last name then first name. On the even days of the month he wants the data the other way, first name followed by last name. Just in case you ever have a boss like that - here is the solution: Create a parameter form for the report. Here we have created Form1. Then create the SQL query text using the choose function as shown:
Below you'll see that when we change the choice field to 2 the last name appears first followed by the first name:
The slight trick to this solution is that we use two Choose function statements in each query. The first choose is used for the Name1 field and the second choose is used for the Name2 field.
Additional Choose Command Information: DoCmd OpenReport in Microsoft Access
|
We now offer web-based SQL/Server application development in partnership with Integrated Databases, Inc. (new projects only). |
|
|