DEVELOPER – Enabling and using Active X Controls

Active X Controls are add-ons available in Microsoft Excel that may be used to enhance usability and functionality of Spreadsheets.

In order to access and use Active X controls, you must enable the DEVELOPER TAB in Excel.

Enabling DEVELOPER TAB in Excel 2007:

Click the Office in the upper left hand corner. Select Excel Options in the lower right.

On the POPULAR options screen, select “Show Developer Tab in the

Enabling DEVELOPER TAB in Excel 2010:

From the FILE tab, Select OPTIONS.

When the Excel Options opens, select Customize Ribbon and check the DEVELOPER tab in the right column.

In previous sessions, we have taled about setting parameters for queries to limit the amount of data returned to Excel.

The use of Active X controls will allow the use of dropdown menus within excel in order to populate selection criteria.

Let’s create a query using the v_job_history table. This will contain the Job_id, job_description, cost_code_id, cost_code_description and cost fields.

First, we will SUM the COST field:

Double Click the COST field heading and select SUM from the Total: criteria

Our query is now summed by job and cost code.

We will put some criteria in the selection to limit the record by job and by a date range.

Since the SUM function has already been applied, we will add criteria by using the at the top of the screen. Select Criteria, Add Criteria.

Fill in the Add Criteria box as follows:

Total : WHERE

Field : job_id

Operator : equals

Value : [JOB]

Click the ADD button. You will be prompted for a value for the job_id. Enter an existing job number and click OK.

The resulting data will represent the job that was selected.

We will continue by adding criteria to limit the date range of the returned data. Again, access the CRITERIA item from the toolbar, and select ADD CRITERIA.

Fill in the Add Criteria box as follows:

Total : WHERE

Field : date_booked

Operator : is between

Value : [START],[END]

Click ADD and enter your date range:

Close the ADD Criteria Screen. You now have a selection based on the parameters we defined.

Return the Data to Excel:

Format the Cells and insert a couple of rows above the queried data. I want to set parameters to pull the information from a particular cell. In this example, we will define job_id as cell A2, Start Date as Cell A3 and End Date as Cell A4

Set the Parameters : Right Click on the table that has DATA stored in it and select TABLE – PARAMETERS.

JOB: (A2)

Start Date : (A3)

End Date : (A4)

Click OK to save the Parameters Screen. When we chance the END DATE and refresh the table, we see different results.

Set an appropriate column width for your data. Right Click within a cell in the Table and select External Data Properties

UNCHECK “Adjust Column Width”. This will stop the query from adjusting the column size every time it is refreshed.

The fist thing we need to do is create a list of jobs that we can use for the selection criteria.

Access a new sheet and execute another query. This query will create our job list. We will use the concatenate function to join the job_id and description field, and then add the job_id as a reference (more on this later). We have also told the query not to include job_status “O” (or overhead) jobs.

Rename the first column to JOB by double clicking on the field heading :

Return the data to Excel:

We are going to use the job_id – description field as our reference in our dropdown box, but we first have to NAME the range. Access the Formulas tab. Highligh all of column A. and Select DEFINE NAME form the TOOLBAR.

If all of these steps were follows, the NEW NAME box will appear and title the range A:A as JOB. Click OK. We have now defined the range of cells as “JOB” for use in our dropdown .

Access the Original sheet with the job cost query.

We will now enable Active X Controls to allow selection of the Job and Dates by using a dropdown menu.

Access the Developer Tab, select INSERT and under the Active X Controls choose (Active X Control).

You will have a cursor that is a “ + “ symbol that will be used to draw the size of the dropdown menu.

Drag and drop a rectangular shape roughly the size of the field you desire.

Right Click on the ComboBox and select Properties.

This is where we will set the criteria for the Combo Box :

The LINKED CELL value will represent where we want to drop the selected data from the ComboBox. In this example, we will select the cell B2 which is adjacent to A2 (the cell that sets our parameter for the query.

The LIST FILL RANGE value will represent what data we want to show in the dropdown box. In this example, we created the NAMED RANGE “JOB” for this purpose.

Enter this information and close the properties box. We are in the “Design Mode”. Access the Design Mode button on the toolbar, click it to turn it OFF.

We may now use the combo box.

Use the dropdown on the right and select a job number. You will notice this selection drops into our cell B2 as defined in the properties tab.

We know that the query parameters are set to refresh based on the value in cell A2. We will replace the current value in cell A2 with a lookup function. This formula will look up the value in B2, compare it to the array in the values in Sheet3 / Coulmns A:B, and return the JOB_ID from the array.

When we refresh the data, we get the results for the selected job.

Turn ON the design mode once again and move the CommandBox over the cells A2 and B2, then turn OFF the Design Mode.

We will now enable a DATE PICKER from the Developer tab. NOTE: excel 2007 does not have a “resident” date picker, but there are plug-ins available via the internet. WARNING : use at your own risk. I tried a couple of variations to mixed results. For the most Part, the Date pickers programmed by other users in Excel 2007 do’t maintain their designated size on your forms. An “eas” way tp remedy this is to upgrade to Office (or Excel) 2010. Excel 2010 has a resident Date Picker, programmed by Microsoft, available in SP6.

From the Developer Tab, select Insert , ActiveX Controls and select the MORE TOOLS option in the lower right.

You will be prompted with a More Controls dialog box.

Select the Microsoft Date and Time Picker Control (6.0) from the list and click OK.

Drag and drop the cursor to create the size of the control.

Right Click the control and select properties. In the Linked Cell box, Type in A3 and close the properties box.

Position the Date Picker Box over cell A3 and resize it if needed. Turn OFF the DESIGN MODE.

Repeat the process for the value in cell A4.

Now the Date Picker allows you to use a dropdown Calendar to select the date.

Note, you may fine tune the ActiveX control boxes with the additional properties (Size, Position, font, etc.)

Select some criteria, and on the DATA tab, click the Refresh All option to pull in data based on your selection criteria.

Once you save the file and re-open it, if you experience problems with the Date Picker Fields resizing on their own, scroll down on the page and back up to “reset” the fields. A great new addition in Excel 2010, but still a little “buggy”.