SlideShare una empresa de Scribd logo
1 de 35
Prepared By: Er. Nawaraj
Bhandari
Office Solution And Development
Chapter:7
Using Macros in Microsoft
Access
What is a Macro?
 A macro is made up of a series of instructions
which are recorded so that they can be played
back later and this can be done by a single
keystroke or command. These commands can act
as a shortcut to enable repetitive tasks to be
completed more efficiently and quickly.
 They can be run from a button, toolbar or menu.
How are Macros Developed?
 There are two ways to develop macros:
 The easiest method is use of built-in macro.
 Another method is for a user to write instructions
using the VBA programming language.
Uses of Macros in Microsoft Access
 Macros can be used in Access for tasks, such as:
 Data entry and data validation
 User interface macros, such as opening forms
and reports and responding to button clicks.
 Filtering records
 Finding records
 Printing
 Navigating between forms and records
 Running queries
Macro Sequence of Production and
Execution
ACTION
with
ARGUMENT
applied
OBJECT
Command
Button
EVENT
Command
Button
clicked
Macro
executed
Result
Objects, Actions, Events, Arguments
and Conditions - 1
 A macro in Access contains an Action or list of
Actions (tasks) applied to an Object in the
database, e.g. a form or command button that
responds to certain Events, e.g. the clicking of a
command button.
 Arguments must be specified for the Actions which
provide information to the Action, e.g. if the
OpenForm Action is used, the Argument would tell
the action which form to open.
Objects, Actions, Events, Arguments
and Conditions - 2
 Conditions can also be set for each of the macro
actions and can be used to determine how the
macro will run, e.g. by testing whether a condition
is True or False.
 The macro is run by attaching it to the event
property of an Object, e.g. opening a form. When
the specified event occurs, the macro will run the
Actions. If any Actions have Conditions applied to
them, they will run providing they have passed the
conditional tests.
Macro Actions - 1
 A macro Action, or command, is an instruction that
informs Access what you want the macro to do.
 There are more than 50 different actions, such as
OpenForm.
Macro Actions - 2
 In Access 2010, they are contained in the
Action drop-down list of the Macro Designer
window and can be selected from the Add
New Action drop-down list or from the Action
Catalog. Actions in the Action Catalog are
grouped by their function.
 To add an Action from the Action Catalog to
the macro window, either double-click the
macro or click and drag it to the macro
window from the Action Catalog.
VBA & SQL
 FORM VALIDATION:
VBA & SQL
 VALIDATION:
VBA & SQL
 INSERTION USING DLOOK-UP:
VBA & SQL
 FORM LOAD EVENT:
VBA & SQL
 FORM LOAD EVENT:
VBA & SQL
LOGIN:
VBA & SQL
LOGIN:
VBA & SQL
Combo box Filtering
VBA & SQL
UPDATE
VBA & SQL
DELETE
Creating a Macro In Access - 1
 Plan your macro - you should plan the
steps that you want a macro to perform
before you record or write it (remember that
we discussed the importance of planning in
Topic 2, Slide 18).
 As in Microsoft Excel and Word, a macro
that is used often can be assigned to a
button.
 Unlike Excel and Word, there is no macro
recorder.
Creating a Macro in Access - 2
 Creating a macro in Access uses a different method to
creating one in Excel or Word, although they can also
be written in VBA in the VB Editor.
 In the 2007 version of Access, a new feature was
added to the interface (which was also new – the
ribbon) called the Macro Designer, which made it
easier to create, edit and automate database tasks.
 In the 2010 version, the Macro Designer was
developed further and the Data Macro feature was
introduced.
Uses of Data Macros
 Verifies that a customer’s payments are up-to-date
before allowing additional charges to be made to
their account
 Calculates the postage and packaging charges on
customers orders in a Sales table
 Calculates the new retail price of a product when
the cost of the product is increased
 Ensuring that an email is sent when a particular
product needs to be re-ordered
Creating a Macro in 2010 - 1
1. Click the Create tab on the Ribbon.
2. Click the Macro button on the Macros and Code
group on the Ribbon.
3. Click the drop-down arrow on the Add New Action
drop-down list and select the action, OR
double-click the action you wish to use in the
Action Catalog (click the plus or minus signs to
expand or collapse the Actions groups), OR
Drag an action from the Action Catalog to the
Macro window.
Creating a Macro in 2010 - 2
4. In the lower part of the window, enter any
Arguments for the Action.
5. To add more Actions to the macro, move to
the next blank Add New Action drop-down
list and repeat steps 3-4 above. The
macro Actions will be executed in the order
that they are listed in the Action column.
Macro Groups
 Several related macros can be stored together
in a macro group .
 Each macro in the macro group is given its own
unique name to identify where each macro
starts and ends.
 Each macro in the macro group must be run
separately by referring to the macro group
name, followed by the macro name, e.g.
mcrPayments. mcrPayments frmPayments
refers to the Open frmPayments macro in the
mcrPayments macro group.
Autoexec Macro
 This macro is used for running functions when the
database is opening, for example, it can
automatically open up a particular screen, display a
message to the user or output data to another
source, such as a spreadsheet.
 To create this type of macro, you need to add your
actions in the Macro Designer and save the macro
with the name ‘Autoexec’. This name is recognised
by Access and it will run the macro as soon as the
database is opened.
Data Entry and Validation
 Macros can be created to require that data be
entered into a control, or to display a dialogue box
that prompts a user for additional information or
informs them of an error that they may have made.
 A macro in a user entry form can set the value for
the control, field or property. This can make data
entry much easier, quicker and more accurate.
Filtering and Finding Fields and Records
 Macros can be written to allow automation
of filtering and finding records.
 Macros can also be used to produce
message boxes and dialogue boxes to be
displayed and allow interaction and help the
user.
Printing
 A macro can be created so that instead of
finding and opening a specific report,
printing it and closing it, a user can print the
report simply by clicking on a specific button
to which the macro has been assigned.
 A macro can also be created that enables a
number of reports to be printed at the same
time, instead of opening a report, printing it,
opening another report, printing it and so on.
Adding a Macro to a Command
Button
 To assign a macro to a Command Button, it must
be added to the Command Button’s On Click
Property. Thus, when a user clicks the button, the
macro is executed.
 Properties such as the OnClick and OnDoubleClick
are called events. An event is a specific action that
occurs on or with a certain object and is usually the
result of an action by a user, such as mouse clicks
or the opening or closing of forms.
Navigating between Forms and
Records
 Macros can be created to enable navigation
between forms and records.
 They can also be created to enable specific
control of records or pages in a form.
Running Queries
 Macros can be created that test whether conditions
are true or false and then execute particular
actions.
 Example: has the customer purchased a product
during the last six weeks? If they have not made a
purchase, a message will be displayed to the user
and the field will be highlighted in red. If they have
made a purchase, the field will be highlighted in
green.
Security and Macros
 Ensure that you set the security level to at least
medium when working with macros in Access.
 Read also the following information from Microsoft
Office website:
http://www.msoffice-tutorial.com/macro-security.php
References
 The Microsoft Office Blog for a demo of Data Macros.
(2010). [Available Online] http://tinyurl.com/6cwrumx
 The Microsoft Office Blog for a demo of the Macro
Designer. (2009). [Available Online]
http://tinyurl.com/67pp46o
 Accessible Data Solutions. (2011). [Available Online]
http://www.accessibledatasolutions.com/articles10/macrovba.htm
Topic 7 – Using Macros in Microsoft
Access
Any Questions?

Más contenido relacionado

La actualidad más candente

E learning excel vba programming lesson 3
E learning excel vba programming  lesson 3E learning excel vba programming  lesson 3
E learning excel vba programming lesson 3Vijay Perepa
 
Introduction to spreadsheet
Introduction to spreadsheetIntroduction to spreadsheet
Introduction to spreadsheetjoy grace bagui
 
Excel VBA programming basics
Excel VBA programming basicsExcel VBA programming basics
Excel VBA programming basicsHang Dong
 
Introduction to Excel VBA/Macros
Introduction to Excel VBA/MacrosIntroduction to Excel VBA/Macros
Introduction to Excel VBA/Macrosarttan2001
 
Architecting mobile application
Architecting mobile applicationArchitecting mobile application
Architecting mobile applicationK Senthil Kumar
 
Report on student-faculty document sharing android project
Report on student-faculty document sharing android projectReport on student-faculty document sharing android project
Report on student-faculty document sharing android projectAlamgir Hossain
 
Excel Excellence (Microsoft Excel training that "sticks"): Formulas
Excel Excellence (Microsoft Excel training that "sticks"): FormulasExcel Excellence (Microsoft Excel training that "sticks"): Formulas
Excel Excellence (Microsoft Excel training that "sticks"): FormulasLaura Winger
 
Basic Web Design In Dreamweaver
Basic Web Design In DreamweaverBasic Web Design In Dreamweaver
Basic Web Design In Dreamweaverjcharnin
 
Using Excel Functions
Using Excel FunctionsUsing Excel Functions
Using Excel FunctionsGautam Gupta
 
A Quick Simple MS Excel Macro
A Quick Simple MS Excel MacroA Quick Simple MS Excel Macro
A Quick Simple MS Excel MacroPranav Ghode
 
How to reduced transformer losses report
How to reduced transformer losses reportHow to reduced transformer losses report
How to reduced transformer losses reportkamal soni
 
VLOOKUP HLOOKUP INDEX MATCH
VLOOKUP HLOOKUP INDEX MATCHVLOOKUP HLOOKUP INDEX MATCH
VLOOKUP HLOOKUP INDEX MATCHMridul Bansal
 

La actualidad más candente (20)

E learning excel vba programming lesson 3
E learning excel vba programming  lesson 3E learning excel vba programming  lesson 3
E learning excel vba programming lesson 3
 
Learn Excel Macro
Learn Excel Macro  Learn Excel Macro
Learn Excel Macro
 
Microsoft Excel - Macros
Microsoft Excel - MacrosMicrosoft Excel - Macros
Microsoft Excel - Macros
 
Vba
Vba Vba
Vba
 
Macros in ms word
Macros in ms wordMacros in ms word
Macros in ms word
 
Introduction to spreadsheet
Introduction to spreadsheetIntroduction to spreadsheet
Introduction to spreadsheet
 
Excel VBA programming basics
Excel VBA programming basicsExcel VBA programming basics
Excel VBA programming basics
 
Introduction to Excel VBA/Macros
Introduction to Excel VBA/MacrosIntroduction to Excel VBA/Macros
Introduction to Excel VBA/Macros
 
Architecting mobile application
Architecting mobile applicationArchitecting mobile application
Architecting mobile application
 
Formula in MS Excel
Formula in MS ExcelFormula in MS Excel
Formula in MS Excel
 
Report on student-faculty document sharing android project
Report on student-faculty document sharing android projectReport on student-faculty document sharing android project
Report on student-faculty document sharing android project
 
Excel formulas tf-jul1605
Excel formulas tf-jul1605Excel formulas tf-jul1605
Excel formulas tf-jul1605
 
Vba part 1
Vba part 1Vba part 1
Vba part 1
 
Excel Macro Magic
Excel Macro MagicExcel Macro Magic
Excel Macro Magic
 
Excel Excellence (Microsoft Excel training that "sticks"): Formulas
Excel Excellence (Microsoft Excel training that "sticks"): FormulasExcel Excellence (Microsoft Excel training that "sticks"): Formulas
Excel Excellence (Microsoft Excel training that "sticks"): Formulas
 
Basic Web Design In Dreamweaver
Basic Web Design In DreamweaverBasic Web Design In Dreamweaver
Basic Web Design In Dreamweaver
 
Using Excel Functions
Using Excel FunctionsUsing Excel Functions
Using Excel Functions
 
A Quick Simple MS Excel Macro
A Quick Simple MS Excel MacroA Quick Simple MS Excel Macro
A Quick Simple MS Excel Macro
 
How to reduced transformer losses report
How to reduced transformer losses reportHow to reduced transformer losses report
How to reduced transformer losses report
 
VLOOKUP HLOOKUP INDEX MATCH
VLOOKUP HLOOKUP INDEX MATCHVLOOKUP HLOOKUP INDEX MATCH
VLOOKUP HLOOKUP INDEX MATCH
 

Similar a Using macros in microsoft access

AIA101.4.Automating Access
AIA101.4.Automating AccessAIA101.4.Automating Access
AIA101.4.Automating AccessDan D'Urso
 
IBM Maximo Tips & Tricks
IBM Maximo Tips & TricksIBM Maximo Tips & Tricks
IBM Maximo Tips & Tricksjohnnyg14
 
AVB201.1 MS Access VBA Module 1
AVB201.1 MS Access VBA Module 1AVB201.1 MS Access VBA Module 1
AVB201.1 MS Access VBA Module 1guest38bf
 
ORACLE FUSION FINANCIAL CLOUD FEATURES - CREATING IMPLEMENTATION USERS
ORACLE FUSION FINANCIAL CLOUD FEATURES - CREATING IMPLEMENTATION USERSORACLE FUSION FINANCIAL CLOUD FEATURES - CREATING IMPLEMENTATION USERS
ORACLE FUSION FINANCIAL CLOUD FEATURES - CREATING IMPLEMENTATION USERSIQ Online Training
 
DF19 South-East Florida Global Gathering
DF19 South-East Florida Global GatheringDF19 South-East Florida Global Gathering
DF19 South-East Florida Global GatheringLuis E. Luciani ☁
 
MVC Pattern. Flex implementation of MVC
MVC Pattern. Flex implementation of MVCMVC Pattern. Flex implementation of MVC
MVC Pattern. Flex implementation of MVCAnton Krasnoshchok
 
Medical Shop - 2.pptx
Medical Shop - 2.pptxMedical Shop - 2.pptx
Medical Shop - 2.pptxsaiproject
 
VBA for technical writers
VBA for technical writersVBA for technical writers
VBA for technical writersTCUK
 
Advanced features of ms office packages 2
Advanced features of ms office packages 2Advanced features of ms office packages 2
Advanced features of ms office packages 2Er. Nawaraj Bhandari
 
A report on mvc using the information
A report on mvc using the informationA report on mvc using the information
A report on mvc using the informationToushik Paul
 
ChircuVictor StefircaMadalin rad_aspmvc3_wcf_vs2010
ChircuVictor StefircaMadalin rad_aspmvc3_wcf_vs2010ChircuVictor StefircaMadalin rad_aspmvc3_wcf_vs2010
ChircuVictor StefircaMadalin rad_aspmvc3_wcf_vs2010vchircu
 
How to Detect a Click Outside a React Component.pptx
How to Detect a Click Outside a React Component.pptxHow to Detect a Click Outside a React Component.pptx
How to Detect a Click Outside a React Component.pptxBOSC Tech Labs
 
Learn Vba excel 2007
Learn Vba excel 2007Learn Vba excel 2007
Learn Vba excel 2007Steve Johnson
 
Spreadsheet Analytical Tools
Spreadsheet Analytical ToolsSpreadsheet Analytical Tools
Spreadsheet Analytical ToolsJoselito Perez
 

Similar a Using macros in microsoft access (20)

MS Access Macros
MS Access MacrosMS Access Macros
MS Access Macros
 
007.macro
007.macro007.macro
007.macro
 
AIA101.4.Automating Access
AIA101.4.Automating AccessAIA101.4.Automating Access
AIA101.4.Automating Access
 
IBM Maximo Tips & Tricks
IBM Maximo Tips & TricksIBM Maximo Tips & Tricks
IBM Maximo Tips & Tricks
 
AVB201.1 MS Access VBA Module 1
AVB201.1 MS Access VBA Module 1AVB201.1 MS Access VBA Module 1
AVB201.1 MS Access VBA Module 1
 
ASP.NET MVC3 RAD
ASP.NET MVC3 RADASP.NET MVC3 RAD
ASP.NET MVC3 RAD
 
ORACLE FUSION FINANCIAL CLOUD FEATURES - CREATING IMPLEMENTATION USERS
ORACLE FUSION FINANCIAL CLOUD FEATURES - CREATING IMPLEMENTATION USERSORACLE FUSION FINANCIAL CLOUD FEATURES - CREATING IMPLEMENTATION USERS
ORACLE FUSION FINANCIAL CLOUD FEATURES - CREATING IMPLEMENTATION USERS
 
DF19 South-East Florida Global Gathering
DF19 South-East Florida Global GatheringDF19 South-East Florida Global Gathering
DF19 South-East Florida Global Gathering
 
MVC Pattern. Flex implementation of MVC
MVC Pattern. Flex implementation of MVCMVC Pattern. Flex implementation of MVC
MVC Pattern. Flex implementation of MVC
 
Medical Shop - 2.pptx
Medical Shop - 2.pptxMedical Shop - 2.pptx
Medical Shop - 2.pptx
 
VBA for technical writers
VBA for technical writersVBA for technical writers
VBA for technical writers
 
Advanced features of ms office packages 2
Advanced features of ms office packages 2Advanced features of ms office packages 2
Advanced features of ms office packages 2
 
Remedy Presentation
Remedy PresentationRemedy Presentation
Remedy Presentation
 
A report on mvc using the information
A report on mvc using the informationA report on mvc using the information
A report on mvc using the information
 
ChircuVictor StefircaMadalin rad_aspmvc3_wcf_vs2010
ChircuVictor StefircaMadalin rad_aspmvc3_wcf_vs2010ChircuVictor StefircaMadalin rad_aspmvc3_wcf_vs2010
ChircuVictor StefircaMadalin rad_aspmvc3_wcf_vs2010
 
How to Detect a Click Outside a React Component.pptx
How to Detect a Click Outside a React Component.pptxHow to Detect a Click Outside a React Component.pptx
How to Detect a Click Outside a React Component.pptx
 
VBA Tips
VBA TipsVBA Tips
VBA Tips
 
Learn Vba excel 2007
Learn Vba excel 2007Learn Vba excel 2007
Learn Vba excel 2007
 
Vb6.0 intro
Vb6.0 introVb6.0 intro
Vb6.0 intro
 
Spreadsheet Analytical Tools
Spreadsheet Analytical ToolsSpreadsheet Analytical Tools
Spreadsheet Analytical Tools
 

Más de Er. Nawaraj Bhandari

Data mining approaches and methods
Data mining approaches and methodsData mining approaches and methods
Data mining approaches and methodsEr. Nawaraj Bhandari
 
Research trends in data warehousing and data mining
Research trends in data warehousing and data miningResearch trends in data warehousing and data mining
Research trends in data warehousing and data miningEr. Nawaraj Bhandari
 
Mining Association Rules in Large Database
Mining Association Rules in Large DatabaseMining Association Rules in Large Database
Mining Association Rules in Large DatabaseEr. Nawaraj Bhandari
 
Introduction to data mining and data warehousing
Introduction to data mining and data warehousingIntroduction to data mining and data warehousing
Introduction to data mining and data warehousingEr. Nawaraj Bhandari
 
Classification and prediction in data mining
Classification and prediction in data miningClassification and prediction in data mining
Classification and prediction in data miningEr. Nawaraj Bhandari
 
Chapter 3: Simplification of Boolean Function
Chapter 3: Simplification of Boolean FunctionChapter 3: Simplification of Boolean Function
Chapter 3: Simplification of Boolean FunctionEr. Nawaraj Bhandari
 
Chapter 5: Cominational Logic with MSI and LSI
Chapter 5: Cominational Logic with MSI and LSIChapter 5: Cominational Logic with MSI and LSI
Chapter 5: Cominational Logic with MSI and LSIEr. Nawaraj Bhandari
 
Chapter 2: Boolean Algebra and Logic Gates
Chapter 2: Boolean Algebra and Logic GatesChapter 2: Boolean Algebra and Logic Gates
Chapter 2: Boolean Algebra and Logic GatesEr. Nawaraj Bhandari
 
Introduction to Electronic Commerce
Introduction to Electronic CommerceIntroduction to Electronic Commerce
Introduction to Electronic CommerceEr. Nawaraj Bhandari
 
Using macros in microsoft excel part 2
Using macros in microsoft excel   part 2Using macros in microsoft excel   part 2
Using macros in microsoft excel part 2Er. Nawaraj Bhandari
 
Application software and business processes
Application software and business processesApplication software and business processes
Application software and business processesEr. Nawaraj Bhandari
 
An introduction to end user software development
An introduction to end user software developmentAn introduction to end user software development
An introduction to end user software developmentEr. Nawaraj Bhandari
 

Más de Er. Nawaraj Bhandari (20)

Data mining approaches and methods
Data mining approaches and methodsData mining approaches and methods
Data mining approaches and methods
 
Research trends in data warehousing and data mining
Research trends in data warehousing and data miningResearch trends in data warehousing and data mining
Research trends in data warehousing and data mining
 
Mining Association Rules in Large Database
Mining Association Rules in Large DatabaseMining Association Rules in Large Database
Mining Association Rules in Large Database
 
Introduction to data mining and data warehousing
Introduction to data mining and data warehousingIntroduction to data mining and data warehousing
Introduction to data mining and data warehousing
 
Data warehouse testing
Data warehouse testingData warehouse testing
Data warehouse testing
 
Data warehouse physical design
Data warehouse physical designData warehouse physical design
Data warehouse physical design
 
Data warehouse logical design
Data warehouse logical designData warehouse logical design
Data warehouse logical design
 
Classification and prediction in data mining
Classification and prediction in data miningClassification and prediction in data mining
Classification and prediction in data mining
 
Chapter 3: Simplification of Boolean Function
Chapter 3: Simplification of Boolean FunctionChapter 3: Simplification of Boolean Function
Chapter 3: Simplification of Boolean Function
 
Chapter 6: Sequential Logic
Chapter 6: Sequential LogicChapter 6: Sequential Logic
Chapter 6: Sequential Logic
 
Chapter 5: Cominational Logic with MSI and LSI
Chapter 5: Cominational Logic with MSI and LSIChapter 5: Cominational Logic with MSI and LSI
Chapter 5: Cominational Logic with MSI and LSI
 
Chapter 4: Combinational Logic
Chapter 4: Combinational LogicChapter 4: Combinational Logic
Chapter 4: Combinational Logic
 
Chapter 2: Boolean Algebra and Logic Gates
Chapter 2: Boolean Algebra and Logic GatesChapter 2: Boolean Algebra and Logic Gates
Chapter 2: Boolean Algebra and Logic Gates
 
Chapter 1: Binary System
 Chapter 1: Binary System Chapter 1: Binary System
Chapter 1: Binary System
 
Introduction to Electronic Commerce
Introduction to Electronic CommerceIntroduction to Electronic Commerce
Introduction to Electronic Commerce
 
Evaluating software development
Evaluating software developmentEvaluating software development
Evaluating software development
 
Using macros in microsoft excel part 2
Using macros in microsoft excel   part 2Using macros in microsoft excel   part 2
Using macros in microsoft excel part 2
 
Testing software development
Testing software developmentTesting software development
Testing software development
 
Application software and business processes
Application software and business processesApplication software and business processes
Application software and business processes
 
An introduction to end user software development
An introduction to end user software developmentAn introduction to end user software development
An introduction to end user software development
 

Último

Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsKarakKing
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...pradhanghanshyam7136
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxVishalSingh1417
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseAnaAcapella
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - Englishneillewis46
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 
ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701bronxfugly43
 
Fostering Friendships - Enhancing Social Bonds in the Classroom
Fostering Friendships - Enhancing Social Bonds  in the ClassroomFostering Friendships - Enhancing Social Bonds  in the Classroom
Fostering Friendships - Enhancing Social Bonds in the ClassroomPooky Knightsmith
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and ModificationsMJDuyan
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...Nguyen Thanh Tu Collection
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxVishalSingh1417
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.MaryamAhmad92
 
Dyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxDyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxcallscotland1987
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin ClassesCeline George
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxEsquimalt MFRC
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfSherif Taha
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxDr. Sarita Anand
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentationcamerronhm
 

Último (20)

Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptx
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please Practise
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - English
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701
 
Fostering Friendships - Enhancing Social Bonds in the Classroom
Fostering Friendships - Enhancing Social Bonds  in the ClassroomFostering Friendships - Enhancing Social Bonds  in the Classroom
Fostering Friendships - Enhancing Social Bonds in the Classroom
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
Dyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxDyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptx
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdf
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptx
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentation
 

Using macros in microsoft access

  • 1. Prepared By: Er. Nawaraj Bhandari Office Solution And Development Chapter:7 Using Macros in Microsoft Access
  • 2. What is a Macro?  A macro is made up of a series of instructions which are recorded so that they can be played back later and this can be done by a single keystroke or command. These commands can act as a shortcut to enable repetitive tasks to be completed more efficiently and quickly.  They can be run from a button, toolbar or menu.
  • 3. How are Macros Developed?  There are two ways to develop macros:  The easiest method is use of built-in macro.  Another method is for a user to write instructions using the VBA programming language.
  • 4. Uses of Macros in Microsoft Access  Macros can be used in Access for tasks, such as:  Data entry and data validation  User interface macros, such as opening forms and reports and responding to button clicks.  Filtering records  Finding records  Printing  Navigating between forms and records  Running queries
  • 5. Macro Sequence of Production and Execution ACTION with ARGUMENT applied OBJECT Command Button EVENT Command Button clicked Macro executed Result
  • 6. Objects, Actions, Events, Arguments and Conditions - 1  A macro in Access contains an Action or list of Actions (tasks) applied to an Object in the database, e.g. a form or command button that responds to certain Events, e.g. the clicking of a command button.  Arguments must be specified for the Actions which provide information to the Action, e.g. if the OpenForm Action is used, the Argument would tell the action which form to open.
  • 7. Objects, Actions, Events, Arguments and Conditions - 2  Conditions can also be set for each of the macro actions and can be used to determine how the macro will run, e.g. by testing whether a condition is True or False.  The macro is run by attaching it to the event property of an Object, e.g. opening a form. When the specified event occurs, the macro will run the Actions. If any Actions have Conditions applied to them, they will run providing they have passed the conditional tests.
  • 8. Macro Actions - 1  A macro Action, or command, is an instruction that informs Access what you want the macro to do.  There are more than 50 different actions, such as OpenForm.
  • 9. Macro Actions - 2  In Access 2010, they are contained in the Action drop-down list of the Macro Designer window and can be selected from the Add New Action drop-down list or from the Action Catalog. Actions in the Action Catalog are grouped by their function.  To add an Action from the Action Catalog to the macro window, either double-click the macro or click and drag it to the macro window from the Action Catalog.
  • 10. VBA & SQL  FORM VALIDATION:
  • 11. VBA & SQL  VALIDATION:
  • 12. VBA & SQL  INSERTION USING DLOOK-UP:
  • 13. VBA & SQL  FORM LOAD EVENT:
  • 14. VBA & SQL  FORM LOAD EVENT:
  • 17. VBA & SQL Combo box Filtering
  • 20. Creating a Macro In Access - 1  Plan your macro - you should plan the steps that you want a macro to perform before you record or write it (remember that we discussed the importance of planning in Topic 2, Slide 18).  As in Microsoft Excel and Word, a macro that is used often can be assigned to a button.  Unlike Excel and Word, there is no macro recorder.
  • 21. Creating a Macro in Access - 2  Creating a macro in Access uses a different method to creating one in Excel or Word, although they can also be written in VBA in the VB Editor.  In the 2007 version of Access, a new feature was added to the interface (which was also new – the ribbon) called the Macro Designer, which made it easier to create, edit and automate database tasks.  In the 2010 version, the Macro Designer was developed further and the Data Macro feature was introduced.
  • 22. Uses of Data Macros  Verifies that a customer’s payments are up-to-date before allowing additional charges to be made to their account  Calculates the postage and packaging charges on customers orders in a Sales table  Calculates the new retail price of a product when the cost of the product is increased  Ensuring that an email is sent when a particular product needs to be re-ordered
  • 23. Creating a Macro in 2010 - 1 1. Click the Create tab on the Ribbon. 2. Click the Macro button on the Macros and Code group on the Ribbon. 3. Click the drop-down arrow on the Add New Action drop-down list and select the action, OR double-click the action you wish to use in the Action Catalog (click the plus or minus signs to expand or collapse the Actions groups), OR Drag an action from the Action Catalog to the Macro window.
  • 24. Creating a Macro in 2010 - 2 4. In the lower part of the window, enter any Arguments for the Action. 5. To add more Actions to the macro, move to the next blank Add New Action drop-down list and repeat steps 3-4 above. The macro Actions will be executed in the order that they are listed in the Action column.
  • 25. Macro Groups  Several related macros can be stored together in a macro group .  Each macro in the macro group is given its own unique name to identify where each macro starts and ends.  Each macro in the macro group must be run separately by referring to the macro group name, followed by the macro name, e.g. mcrPayments. mcrPayments frmPayments refers to the Open frmPayments macro in the mcrPayments macro group.
  • 26. Autoexec Macro  This macro is used for running functions when the database is opening, for example, it can automatically open up a particular screen, display a message to the user or output data to another source, such as a spreadsheet.  To create this type of macro, you need to add your actions in the Macro Designer and save the macro with the name ‘Autoexec’. This name is recognised by Access and it will run the macro as soon as the database is opened.
  • 27. Data Entry and Validation  Macros can be created to require that data be entered into a control, or to display a dialogue box that prompts a user for additional information or informs them of an error that they may have made.  A macro in a user entry form can set the value for the control, field or property. This can make data entry much easier, quicker and more accurate.
  • 28. Filtering and Finding Fields and Records  Macros can be written to allow automation of filtering and finding records.  Macros can also be used to produce message boxes and dialogue boxes to be displayed and allow interaction and help the user.
  • 29. Printing  A macro can be created so that instead of finding and opening a specific report, printing it and closing it, a user can print the report simply by clicking on a specific button to which the macro has been assigned.  A macro can also be created that enables a number of reports to be printed at the same time, instead of opening a report, printing it, opening another report, printing it and so on.
  • 30. Adding a Macro to a Command Button  To assign a macro to a Command Button, it must be added to the Command Button’s On Click Property. Thus, when a user clicks the button, the macro is executed.  Properties such as the OnClick and OnDoubleClick are called events. An event is a specific action that occurs on or with a certain object and is usually the result of an action by a user, such as mouse clicks or the opening or closing of forms.
  • 31. Navigating between Forms and Records  Macros can be created to enable navigation between forms and records.  They can also be created to enable specific control of records or pages in a form.
  • 32. Running Queries  Macros can be created that test whether conditions are true or false and then execute particular actions.  Example: has the customer purchased a product during the last six weeks? If they have not made a purchase, a message will be displayed to the user and the field will be highlighted in red. If they have made a purchase, the field will be highlighted in green.
  • 33. Security and Macros  Ensure that you set the security level to at least medium when working with macros in Access.  Read also the following information from Microsoft Office website: http://www.msoffice-tutorial.com/macro-security.php
  • 34. References  The Microsoft Office Blog for a demo of Data Macros. (2010). [Available Online] http://tinyurl.com/6cwrumx  The Microsoft Office Blog for a demo of the Macro Designer. (2009). [Available Online] http://tinyurl.com/67pp46o  Accessible Data Solutions. (2011). [Available Online] http://www.accessibledatasolutions.com/articles10/macrovba.htm
  • 35. Topic 7 – Using Macros in Microsoft Access Any Questions?