dcsimg
 

How to Add an "Update Data from My Database" Button to a Minitab Menu or Toolbar

Many of us have data stored in a database or file that we need to analyze on a regular basis. If you're in that situation and you're using Minitab Statistical Software, here's how you can save some time and effort by automating the process.

When you're finished, instead of using File > Query Database (ODBC) each time you want to perform analysis on the most up-to-date set of data, you can add a button to a menu or toolbar that will update the data. To do this you will need to:

A. Create an Exec (.MTB) file that retrieves the data and replaces the current data.
B. Add a shortcut to that file to either a menu or toolbar.

Creating an Exec (.MTB) file

First, I'll create a Minitab script or "exec" that pulls in new data to my worksheet. This is easier than it might sound. 

1. Use File > Query Database (ODBC) to import the desired data. I have several fields that need to be updated, so I can just use File > Query Database (ODBC) repeatedly to pull required fields from multiple tables.

2. Open the History window by clicking the yellow notepad icon and select the ODBC commands/subcommands.

3. Right-click the selected commands and choose Save As...

4. In the Save As... dialog box, choose Exec Files (*MTB) from the Save as Type: drop-down. Choose a filename and location—for example, I'm going to save this as GetData.MTB on my desktop.

5. In Minitab, choose Tools > Notepad.

6. In Notepad, choose File > Open. Change Files of Type: to All Files, and open the .MTB file you just created.

7. Do the following for each ODBC command and corresponding subcommands: 

  • Replace the period (.) at the end of the last subcommand with a semi-colon (;).
     
  • Add the following below the last subcommand, including the period (In this example, 'Date' and 'Measurement' are the columns I want to store the imported data in. Typically, these share the same name as the fields they are imported from):

Columns 'Date' 'Measurement'.

For example:


Make sure the column names you specify in the Columns subcommand already exist in the Minitab worksheet. You also can use column numbers such as C1 C2, without single-quotes. If you're importing many columns, instead of naming each one individually, you can specify a range like this: Columns C1-C10. 

8. Choose File > Save and then close Notepad. This exec will run the commands and update my data sheet each time it is run.

But I want to make it even easier. Instead of opening the script when I want to use it, I want to be able to just select it from a menu.

Adding a Shortcut to a Minitab Menu

To add the .MTB file to a menu in Minitab, I do the following:

1. Choose Tools > Customize.

2. Click the Tools tab.

3. Click  for New (Insert) as shown. If you hover the cursor over the button, the ToolTip displays New (Insert).

4. Enter a name for the button, and then press [Enter]. (For example, enter Get My Data.)

5. Click  to view the Open files dialog box. From Files of type, choose All Files (*.*) then navigate to the .MTB file and double-click it. The dialog box will look like this:

6. Click CloseNow I can run the macro by choosing Tools > Get My Data.

I can also add the macro to a menu other than Tools. 

Adding a Button to a Minitab Toolbar

But now that I think about it, I really don't even want to bother with a menu. I'd prefer to just click on a button and have my data updated automatically. It's easy to do. 

7. Choose Tools > Customize.

8. On the Commands tab, under Categories, choose Tools. Note: If you did not complete steps 5 and 6, the macro will not yet appear in the list.

9. Click and drag Get My Data to the desired place on a menu or toolbar.

Basically, that's it. However, you can change what is displayed on the toolbar by right-clicking the button or text while the Tools > Customize dialog box is open. You can select Image, Text, or Image and Text

To change the image that is displayed, choose Edit Button Image. To change the text that is displayed, choose Name Button. As shown below, I have inserted a red button with a circular arrow in the main toolbar, and named it "Get My Data."  

Now I can update my data at any time by clicking on the new button. And if you've been following along, so can you!  If you don't already have Minitab Statistical Software and you'd like to give it a try, download the free 30-day trial

 

 

Comments

blog comments powered by Disqus