3 access lastname firstname a03 results snip2...

8
= Copyright © 2011 by Pearson Education Inc. publishing as Prentice Hall. All rights reserved. From Skills for Success with Microsoft® Office 2010 Vol. 1 Create Forms | Microsoft Access Chapter 3 More Skills: SKILL 14 | Page 1 of 8 A macro is a set of saved actions that you can use to automate tasks. For example, a macro can open several database objects with a single click, or display a message whenever a form or report is opened. Macros are created in the Macro Builder—an object tab with prebuilt commands that you can select and modify to build a macro. To complete this database, you will need the following file: a03_Results You will save your files as: Lastname_Firstname_a03_Results Lastname_Firstname_a03_Results_Snip1 Lastname_Firstname_a03_Results_Snip2 1. Start Access. Locate and open the file a03_Results. Save the file in your Access Chapter 3 folder as Lastname_Firstname_a03_Results If the security message displays, enable the content. 2. On the Create tab, in the Macros & Code group, click the Macro button to display the Macro Builder and the Macro Tools Design tab. Compare your screen with Figure 1. The Macro Builder displays an area for adding actions and the Action Catalog lists common macro actions—prebuilt sets of instructions that perform tasks when the macro is run. Access CHAPTER 3 More Skills 14 Create Macros Figure 1 Action Catalog Macro Tools Design tab Macro builder

Upload: others

Post on 03-Sep-2021

1 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: 3 Access Lastname Firstname a03 Results Snip2 1.wps.prenhall.com/wps/media/objects/10548/10801251/More... · 2010. 8. 20. · Start Access. Locate and open the file a03_Results. Save

=

Copyright © 2011 by Pearson Education Inc. publishing as Prentice Hall. All rights reserved.From Skills for Success with Microsoft® Office 2010 Vol. 1

Create Forms | Microsoft Access Chapter 3 More Skills: SKILL 14 | Page 1 of 8

� A macro is a set of saved actions that you can use to automate tasks. For example, a macro canopen several database objects with a single click, or display a message whenever a form or reportis opened.

� Macros are created in the Macro Builder—an object tab with prebuilt commands that youcan select and modify to build a macro.

To complete this database, you will need the following file:� a03_Results

You will save your files as:� Lastname_Firstname_a03_Results� Lastname_Firstname_a03_Results_Snip1� Lastname_Firstname_a03_Results_Snip2

1. Start Access. Locate and open the file a03_Results. Save the file in your Access Chapter3 folder as Lastname_Firstname_a03_Results If the security message displays, enable thecontent.

2. On the Create tab, in the Macros & Code group, click the Macro button to display theMacro Builder and the Macro Tools Design tab. Compare your screen with Figure 1.

The Macro Builder displays an area for adding actions and the Action Catalog listscommon macro actions—prebuilt sets of instructions that perform tasks when themacro is run.

AccessCHAPTER 3

More Skills 14 Create Macros

Figure 1

Action Catalog

Macro ToolsDesign tab

Macro builder

2140004Access_C03_MS14.qxd 6/29/10 1:44 PM Page 1

Page 2: 3 Access Lastname Firstname a03 Results Snip2 1.wps.prenhall.com/wps/media/objects/10548/10801251/More... · 2010. 8. 20. · Start Access. Locate and open the file a03_Results. Save

Copyright © 2011 by Pearson Education Inc. publishing as Prentice Hall. All rights reserved.From Skills for Success with Microsoft® Office 2010 Vol. 1

3. In the Action Catalog, under Actions, expand Filter/Query/Search, and then double-click OpenQuery. Compare your screen with Figure 2.

When you add an action to the Macro Builder, the action displays in a box with itsaction arguments—additional instructions that determine how the macro actionshould run. The OpenQuery action has three arguments: Query Name, View, and DataMode.

Create Forms | Microsoft Access Chapter 3 More Skills: SKILL 14 | Page 2 of 8

4. In the OpenQuery action, click the Query Name arrow, and then, from the list,click Stage Results.

Figure 2

Filter/Query/Searchactions

OpenQueryaction

Action arguments

2140004Access_C03_MS14.qxd 6/29/10 1:44 PM Page 2

Page 3: 3 Access Lastname Firstname a03 Results Snip2 1.wps.prenhall.com/wps/media/objects/10548/10801251/More... · 2010. 8. 20. · Start Access. Locate and open the file a03_Results. Save

5. In the OpenQuery action, click the View arrow, and then click Design. Compare yourscreen with Figure 3.

The action arguments specify that the Stage Results query should open in Design viewwhen the macro is run.

Copyright © 2011 by Pearson Education Inc. publishing as Prentice Hall. All rights reserved.From Skills for Success with Microsoft® Office 2010 Vol. 1

Create Forms | Microsoft Access Chapter 3 More Skills: SKILL 14 | Page 3 of 8

6. Click Save . In the Save As dialog box, type Open Stage Results Query and then click OK.In the Navigation Pane, notice that the saved macro displays in the Macros group.

7. On the Design tab, in the Tools group, click the Run button. In the Stage Results query,notice that the year criterion specifies the year 2011. Scroll to the right, and notice that theBracket criteria limit the results to the male and female professional brackets.

8. In the Results group, click the Run button. In the first record, change the names Earnestand Wallaert to your own first and last name, and then Close the query.

9. With the Macro Builder displayed, Start the Snipping Tool, click the New buttonarrow, and then click Full-screen Snip. Save the snip your Access Chapter 3 folder asLastname_Firstname_a03_Results_Snip1 and then Close the Snipping Tool mark-upwindow.

10. Close the Macro Builder. In the Navigation Pane, under Reports, double-click StageResults to display the results of the Stage Results query in the report.

11. Switch to Layout view. In the Controls group, click the Button (Form Control) button .

Figure 3

Action argumentschanged

2140004Access_C03_MS14.qxd 6/29/10 1:44 PM Page 3

Page 4: 3 Access Lastname Firstname a03 Results Snip2 1.wps.prenhall.com/wps/media/objects/10548/10801251/More... · 2010. 8. 20. · Start Access. Locate and open the file a03_Results. Save

12. Position the pointer in the blank column to the right of the report. When the orangeline displays, as shown in Figure 4, click the mouse button to insert the button into the layout’s summary row.

Copyright © 2011 by Pearson Education Inc. publishing as Prentice Hall. All rights reserved.From Skills for Success with Microsoft® Office 2010 Vol. 1

Create Forms | Microsoft Access Chapter 3 More Skills: SKILL 14 | Page 4 of 8

Figure 4

Button will beinserted into

summary row

13. With the orange selection border still around the button, click the button one time to enterText Editing mode. Select the existing text, and then type Open Query

14. With the button still in Text Edit mode, on the Design tab, in the Tools group, click theProperty Sheet button.

2140004Access_C03_MS14.qxd 6/29/10 1:44 PM Page 4

Page 5: 3 Access Lastname Firstname a03 Results Snip2 1.wps.prenhall.com/wps/media/objects/10548/10801251/More... · 2010. 8. 20. · Start Access. Locate and open the file a03_Results. Save

15. Click the property sheet Event tab. Click the On Click arrow, and then click Open StageResults Query. Compare your screen with Figure 5.

The Open Stage Results Query macro will run whenever the button is clicked.

Copyright © 2011 by Pearson Education Inc. publishing as Prentice Hall. All rights reserved.From Skills for Success with Microsoft® Office 2010 Vol. 1

Create Forms | Microsoft Access Chapter 3 More Skills: SKILL 14 | Page 5 of 8

Figure 5

On Click propertychanged

16. Close the property sheet, click Save , and then switch to Report view.

17. In the report, click the Open Query button. In the query, in the Year column Criteria box,change the year to 2012 Save , and then Close the query.

18. Close the Stage Results report, and then open the report in Report view to display theresults for 2012.

2140004Access_C03_MS14.qxd 6/29/10 1:44 PM Page 5

Page 6: 3 Access Lastname Firstname a03 Results Snip2 1.wps.prenhall.com/wps/media/objects/10548/10801251/More... · 2010. 8. 20. · Start Access. Locate and open the file a03_Results. Save

19. Switch to Layout view. On the Design tab, in the Tools group, click the Property Sheetbutton. Click the Selection type arrow, and then click Report to display the report properties. Compare your screen with Figure 6.

Copyright © 2011 by Pearson Education Inc. publishing as Prentice Hall. All rights reserved.From Skills for Success with Microsoft® Office 2010 Vol. 1

Create Forms | Microsoft Access Chapter 3 More Skills: SKILL 14 | Page 6 of 8

Figure 6

Report selected

20. In the property sheet, click the On Load box, and then click the displayed Build button .In the Choose Builder dialog box, be sure that Macro Builder is selected, and then clickOK.

21. In the Stage Results : Report : On Load object tab, click the Add New Action arrow, andthen, from the list, click Beep.

The Beep action has no arguments.

22. Below the Beep action just inserted, click the Add New Action arrow, and then, from thelist, click MessageBox to insert the MessageBox action.

The MessageBox action has four action arguments: Message, Beep, Type, and Title.

23. If necessary, in the Message Box action, click in the Message box. Type If you need to updatethe Stage Results query, click the Open Query button, and then reopen this report.

24. Click the Type arrow, and then from the list, click Warning?.

2140004Access_C03_MS14.qxd 6/29/10 1:44 PM Page 6

Page 7: 3 Access Lastname Firstname a03 Results Snip2 1.wps.prenhall.com/wps/media/objects/10548/10801251/More... · 2010. 8. 20. · Start Access. Locate and open the file a03_Results. Save

25. In the Title box, type Does the query need to be updated? Compare your screen with Figure 7.

Copyright © 2011 by Pearson Education Inc. publishing as Prentice Hall. All rights reserved.From Skills for Success with Microsoft® Office 2010 Vol. 1

Create Forms | Microsoft Access Chapter 3 More Skills: SKILL 14 | Page 7 of 8

Figure 7

Beep andMessageBox

actions added

MessageBoxaction arguments

changed

Figure 8

Three macroactions

26. Click the Add New Action arrow, and then click Beep.

27. Click Save , and then compare your screen with Figure 8.

2140004Access_C03_MS14.qxd 6/29/10 1:44 PM Page 7

Page 8: 3 Access Lastname Firstname a03 Results Snip2 1.wps.prenhall.com/wps/media/objects/10548/10801251/More... · 2010. 8. 20. · Start Access. Locate and open the file a03_Results. Save

28. Start the Snipping Tool, click the New button arrow, and then click Full-screen Snip. Save the snip in your Access Chapter 3 folder as Lastname_Firstname_a03_Results_Snip2 and then Close the Snipping Tool mark-upwindow.

29. In the Close group, click the Close button. In the report, Close the property sheet, andthen click Save .

Unlike the macro created previously, this macro will not display in the Navigation Panewhen you save it. This macro is saved as part of the report and cannot be used in otherforms or reports.

30. Close , and then reopen the report. Compare your screen with Figure 9.

The MessageBox arguments that you define in the Macro Builder display in a messagebox. Here, the title bar, icon, and message are defined by the action arguments.

Copyright © 2011 by Pearson Education Inc. publishing as Prentice Hall. All rights reserved.From Skills for Success with Microsoft® Office 2010 Vol. 1

Create Forms | Microsoft Access Chapter 3 More Skills: SKILL 14 | Page 8 of 8

Figure 9

Message boxWarning? icon

Title

Message

31. Read the message displayed by the macro, and then click OK.

32. In the report, click the Open Query button that you inserted. In the query, change the Yearcolumn Criteria box to 2011 Save and then Close the query.

33. Close , and then reopen the report. In the message that appears, click OK. If yourinstructor asks you to print this project, print the report.

34. Close the report, and then Exit Access.

35. Print the snips or submit the files as directed by your instructor.

� You have completed More Skills 14

2140004Access_C03_MS14.qxd 6/29/10 1:44 PM Page 8