MACRO
1
NỘI DUNG
1
MACRO LÀ GÌ?
2
PHÂN LOẠI MACRO
3
STANDALONE MACRO
4
DATA MACRO
5
CONNECTING MACROS TO FORM
2
MACRO LÀ GÌ?
Macro là tập hợp các lệnh được định sẵn
Macro có thể liên kết các đối tượng trong CSDL
Macro được dùng khi
Có các hành động thường xuyên lặp lại (tự động hóa
công việc)
Kết hợp các hành động đơn giản
3
PHÂN LOẠI MACRO
Standalone macro
Là một đối tượng của CSDL
Sau khi được tạo và lưu thì nó xuất hiện trong Navigation
pane
Data macro
Được lưu trữ như một phần của Table
Có thể thiết lập để thực thi macro trước hoặc sau khi một
bản ghi được thêm vào, chỉnh sửa hoặc xóa
Thường dùng để thiết lập Validation rule hoặc default value
Embedded macro
Được lưu trữ như một phần của form hoặc report
Macro chỉ được thực thi khi form hoặc report hoặc một đối
tượng trên form hoặc report chịu tác động của một sự kiện
4
STANDALONE MACRO
5
TẠO STANDALONE MACRO
1. Click nút Macro trên Create tab
6
7
TẠO STANDALONE MACRO
2. Chọn Action trong khung Add New Action hoặc
Action catalog
8
TẠO STANDALONE MACRO
3. Nhập đối số cho action
4. Thực thi macro (Run)
9
MỘT SỐ ACTION THÔNG DỤNG
10
11
12
THIẾT LẬP ĐỐI SỐ CHO ACTION
13
MỘT SỐ THAO TÁC KHI THIẾT KẾMACRO
Di chuyển/ xóa Action
14
MỘT SỐ THAO TÁC KHI THIẾT KẾMACRO
Copy action
Giữ phím Ctrl, kéo Action đến vị trí mong muốn
Thêm comment
Add new action chọn Comment
15
SUBMARCOS
Subroutines: a set of actions (commands) with a
name
Subroutines can be performed by calling it using
its name
In Access, subroutines are called submacros
Submacros contain actions or other submacros
16
CREATE A SUBMACRO
1. Display the Action catalog and the Program Flow
(if they are not displayed)
2. Drag the Submacro to the macro or double click
on the Submacro
3. Type a name for the submacro
4. Enter the submacro’s actions and arguments
17
18
19
20
AUTORUN MACRO
To create a macro that automatically runs when
the database opens: just name the macro
AutoExec
If you do not want the AutoExec macro to run,
hold down the Shift key while the database is
loading
21
ASSIGNING MACROS TO KEYS
Create a macro group named AutoKeys
AutoKeys contains submacros with the name of
keys (or key combinations) on the keyboard
Access runs the appropriate submacro when you
press the key
22
23
NAME A KEY-ASSIGNMENTMACRO
^ indicate Ctrl key
+ indicate Shiftkey
Put {} around key names that are more than one
letter long
24
OPENING DB THAT CONTAIN MACROS
25