2
This month we will use our Basic Bike append query to help create a similar query for the Deluxe Bike data and learn a bit more about how macros operate by adding some new steps to the Budget Process macro. Set Warnings Macro Action So far, the macro we created has three steps. It opens a form that contains some default assumptions and then processes two queries that empty a table and append new data. When you run it, Access will display a warning message (see Figure 1) that tells you that you are about to run a query that will modify data in a table and asks you to confirm that you want to run the query. When you click Yes, another warning appears to tell you how many records you will be deleting and, because you can’t undo the action, again asks you to confirm that you want to proceed. There’s an action that you can add to the beginning of a macro that will pre- vent warning messages like this from dis- playing. It’s called Set Warnings. Open the Budget Process macro in Design View. We want this action to be first, so insert a new row at the top. There are two ways to do this: Right-click on the first row and select Insert, or use the Insert Rows but- ton on the Macro Design Ribbon. In the new row, select the Set Warnings action from the dropdown list. If it isn’t in the list, click the Show All Actions button on the Macro Design Ribbon, and then try the dropdown menu again. The possible arguments for the Set Warnings action are Yes and No. If the argument is set to No at the beginning of a macro, it will process your queries without displaying the warnings. Once your queries are processed, however, you’ll need to change the Set Warnings argument back to Yes so that you can see any warnings that might appear as you continue to work on the database and develop new queries. That means adding another Set Warnings action after the query-related actions— only this one should have the argument set to Yes (see Figure 2). Message Box Macro Action Now that the warnings are suppressed when you run the macro, you won’t see anything happen onscreen when you click the run button—so you might wonder if or when it’s completed. Add the MsgBox action at the end of the process to display a pop-up message that tells you when the process is complete. The MsgBox arguments enable you to enter the mes- sage you want to display, add a beep, and even choose the type of message box or create a title for your message. A sim- ple message such as “Process Complete” should be sufficient for our purposes. Deluxe Bike Sales Budget Query As you work to create a process, it isn’t unusual to find the need to create multi- TECHNOLOGY ACCESS Master Budget Project: Set Warnings and MsgBox Actions By Patricia Cox Figure 1. Query Warning Message 62 STRATEGIC FINANCE I March 2012

TECHNOLOGY ACCESS - Strategic Finance...TECHNOLOGY ACCESS Master Budget Project: Set Warnings and MsgBox Actions By Patricia Cox Figure 1. Query Warning Message 62 STRATEGIC FINANCEI

  • Upload
    others

  • View
    1

  • Download
    0

Embed Size (px)

Citation preview

Page 1: TECHNOLOGY ACCESS - Strategic Finance...TECHNOLOGY ACCESS Master Budget Project: Set Warnings and MsgBox Actions By Patricia Cox Figure 1. Query Warning Message 62 STRATEGIC FINANCEI

This month we will use our Basic Bike

append query to help create a similar

query for the Deluxe Bike data and learn

a bit more about how macros operate by

adding some new steps to the Budget

Process macro.

Set Warnings Macro ActionSo far, the macro we created has three

steps. It opens a form that contains

some default assumptions and then

processes two queries that empty a table

and append new data. When you run it,

Access will display a warning message

(see Figure 1) that tells you that you are

about to run a query that will modify

data in a table and asks you to confirm

that you want to run the query. When

you click Yes, another warning appears

to tell you how many records you will be

deleting and, because you can’t undo

the action, again asks you to confirm

that you want to proceed.

There’s an action that you can add to

the beginning of a macro that will pre-

vent warning messages like this from dis-

playing. It’s called Set Warnings. Open the

Budget Process macro in Design View. We

want this action to be first, so insert a

new row at the top. There are two ways

to do this: Right-click on the first row and

select Insert, or use the Insert Rows but-

ton on the Macro Design Ribbon. In the

new row, select the Set Warnings action

from the dropdown list. If it isn’t in the

list, click the Show All Actions button on

the Macro Design Ribbon, and then try

the dropdown menu again.

The possible arguments for the Set

Warnings action are Yes and No. If the

argument is set to No at the beginning

of a macro, it will process your queries

without displaying the warnings.

Once your queries are processed,

however, you’ll need to change the Set

Warnings argument back to Yes so that

you can see any warnings that might

appear as you continue to work on the

database and develop new queries. That

means adding another Set Warnings

action after the query-related actions—

only this one should have the argument

set to Yes (see Figure 2).

Message Box Macro ActionNow that the warnings are suppressed

when you run the macro, you won’t see

anything happen onscreen when you click

the run button—so you might wonder if

or when it’s completed. Add the MsgBox

action at the end of the process to display

a pop-up message that tells you when

the process is complete. The MsgBox

arguments enable you to enter the mes-

sage you want to display, add a beep,

and even choose the type of message box

or create a title for your message. A sim-

ple message such as “Process Complete”

should be sufficient for our purposes.

Deluxe Bike SalesBudget QueryAs you work to create a process, it isn’t

unusual to find the need to create multi-

TECHNOLOGY

ACCESSMaster Budget Project: Set Warnings and MsgBox Actions

By Patricia Cox

Figure 1. Query Warning Message

62 S T R AT E G IC F I N A N C E I M a rc h 2 0 1 2

Page 2: TECHNOLOGY ACCESS - Strategic Finance...TECHNOLOGY ACCESS Master Budget Project: Set Warnings and MsgBox Actions By Patricia Cox Figure 1. Query Warning Message 62 STRATEGIC FINANCEI

ple queries that are similar. In these cas-

es, you can create a new query by start-

ing with the design of an existing query.

This saves a lot of time. We will do this

to make a query that will append budget

values for the Deluxe Bike.

To begin, select the Append Budget

Values for Basic Bike query. Make a copy

of this query and save it as “Append Bud-

get Values for Deluxe Bike.” To do this,

click on the Office button, go to Save As,

and select Save Object As. You can also

right-click the Append Budget Values for

Basic Bike query in the Objects List and

select Copy. Then right-click the Objects

List and select Paste.

With our newly copied query, we’re

now ready to modify it for the Deluxe

Bike. Open the query in Design View and

modify the Budget Count field to

contain:

Budget Count: Int([Forms]![Budget

Assumptions Entry Form]![Sales

UnitsDeluxe]*(1+[Forms]![Budget

Assumptions Entry Form]![Growth

Deluxe])^([ID]-1)).

Then, for the Product Number field,

change the Criteria line from 1 to 2.

Save your changes.

With this new query ready, we can

add a new OpenQuery action to the

macro. Open the macro in Design View

and insert a new row below the action

for the Basic Bike query. Then save the

macro. When you are done, the macro

Design View should appear like the

example in Figure 2.

Don’t forget that the database file for

this month, SF_MAR_2012.mdb, is avail-

able in the IMA Publications Discussion

Group of LinkupIMA. It’s a great place to

review the macro or queries we’ve devel-

oped. Remember to enable the macro

content when you open the database.

Since you didn’t create the database,

Access will display a security warning

and disable the macro content. Click on

the warning’s Options button and select

“Enable this content.” Otherwise, the

macros won’t work at all.

Next month we will take a look at a

slightly different approach to building

the database that we’d take if our bud-

get included many products instead of

just two. As always, please feel free to

e-mail me with questions. SF

Patricia Cox has taught Excel and Access

to management accounting students

and other college majors and has

consulted with local area businesses to

create database reporting systems since

1998. She is also a member of IMA’s

Greater Milwaukee Chapter. To send

Patricia a question to address in the

Access column, e-mail her at

[email protected].

Figure 2. Budget Process Macro Design View

M a rc h 2 0 1 2 I S T R AT E G IC F I N A N C E 63