Macros

849 views

Published on

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
849
On SlideShare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
36
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Macros

  1. 1. A2 MODULE 6 MACROS & COMMAND BUTTONSA macro is a set of one or more actions that each performs a particular operation, such as opening a formor printing a report. Macros can help you to automate common tasks. For example, you can run a macrothat prints a report when a user clicks a command button. 1. In the Database Window, click Macros under Objects. 2. Click the New button on the Database window toolbar. 3. In the Action column, click in the first cell and then click the arrow to display the action list. 4. Browse through the actions you can apply. Below is a list explaining the actions in more detail: Action Details ApplyFlter Restricting data FindNext, FindRecord Move through data GoToControl, GoToPage, GoToRecord Move through data RunCommand Execute a form or report Quit Exit MS Access OpenQuery, RunCode, RunMacro, Run a macro, procedure or query RunSQL RunApp Run another application CanelEvent, Quite, StopAllMacros, Stop execution StopMacro OutputTo, SendObject Export MS Access objects to other applications TransferDatabase, TransferSpreadsheet, Transfer data between MS Access TransferText and other formats. CopyObject Copy Rename RenameMrs Neal 04/07/2012
  2. 2. Action Details Save Save DeleteObject Delete Maximize Maximize window when opened Minimize Minimize window when opened MoveSize Resize a window Restore Restore Close Close an object OpenForm, OpenModule, OpenQuery, Open or an object OpenReport, OpenTable OpenForm, OpenQuery, OpenReport, Print an object Printout SelectObject Select an object SetValue Set a value of a field, control or property RepaintObject, Requery, ShowAllRecords Display updated data or screen AddMenu To create a custom menu bar, shortcut menu SetMenuItem Set menu items on the custom menu bar or shortcut menu. Echo, Hourglass, MsgBox, SetWarnings Display information on screen SendKeys Generate keystrokes ShowToolbar Display or hide command bar Beep Sound of a beepPut it into Practice: 1. Open a database you have previously created (ensure it includes a form)Mrs Neal 04/07/2012
  3. 3. 2. In the Database Window select Macros and click New. 3. Click the drop down box within the Action column, and select Maximize. 4. Save the macro as mrcMax, and close the macro window. 5. Now open a form you have crated in Design View. 6. In the top left hand corner (at the insertion point of the rulers) right- click the black square and select Properties. 7. The Form Properties box is displayed. 8. Click the Event tab. 9. Click On Open. 10. Click the down arrow; a list of macros you have set will be displayed. Choose mcrMax. 11. Close the form. 12. Open the form, you will see the macro runs as soon as the form opens, and the form window is maximised. Grouping Relating Macros The following example shows how you can group two macros under one name. 1. You will need to have already created a database, which contains a form. 2. In the database window select Macros and click New. 3. Click the Macros Names icon. 4. A Marco name column will be displayed. Enter the name mcrAddClient. 5. In the Action column select the OpenForm. 6. In the bottom half of the window select the relevant form (Form Name) this specifies which form is to be opened.Mrs Neal 04/07/2012
  4. 4. 7. When the form is opened we want to be able to add a new record, therefore we need another action. In the second line of the Action column select GoToRecord, within the Record Action argument select New: 8. Save the macro as mmnuClient. 9. Run the macro by clicking the Run icon on the toolbar. 10. The form should open ready for you to enter a new record. Command ButtonsYou can create a command button on your own, or you can have Microsoft Access create your commandbutton for you using a wizard. A wizard speeds up the process of creating a command button because itdoes all the basic work for you. When you use a wizard, Access prompts you for information, and thencreates the command button based on your answers.You can create over 30 different types of command buttons by using the Command Button Wizard. Forexample, you can create a command button that finds a record, prints a record, or save. 1. Open a form in Design View. 2. In the toolbox, click the Command Button tool. 3. On the form, click where you want to place the command button. 4. Follow the directions in the wizard dialog boxes. In the last dialog box, click Finish to display the command button in Design View.Mrs Neal 04/07/2012

×