Вы находитесь на странице: 1из 40

DATABASE MANAGEMENT

S y s t e m

1
VII. Macros
Macro Object enA MS Access vaCaPasabBa¢armantYnaTIbegáInel,Ón
kargarenAkñúg MS Access vaGacCYyeyIgkñúgkarbegáIt Button, Menu cg
Object Application bBa©ÚlKñasMrab;eRbIR)as; pÞal;elIkic©karrbs;eyIgnig

GacykkmµviFIepSgmkrt;enAkñúg Ms Access b¤]bmafaeyIgman Table

Forms, ReportseRcIneyIgGaceRbI Macro edIm,IdMeNIrkarebIkbiTelIkic©kar


enH.
Prepared by Sann Sothearath 2
 karbegþIt Macro Autoexec
eyIgeRbI Macro Autoexec sMrab;dMeNIrkarcUleTAebIk Form edays½VyRbvtþi
enAeBlEdleyIgebIk Database .
 enAkñúg Database Windows  Macro Object New

 ]TahrN_faeyIgman Form Main Switchboard


 Save Macro edaydak;eQµaHfa Autoexec

Prepared by Sann Sothearath 3


 karbegáIt Open Button
 kñúg Database Windows  Macro  New
 eFVI Button eQµaH Open edIm,IebIk Suppliers kñúg

Macro Window eFVIdUcxageRkamenH ³


Action Action Arguments
Open Form Name : Suppliers

 Save Macro edaydak;eQµaHfa McrSuppliers


Prepared by Sann Sothearath 4
 karbegáIt Close Button
kñúg Database Window Macro New
 

eFVI Button eQµaH Close edIm,IbiT Form Categories


kñúg Macro Window eFVIdUcxageRkamenH


Action Action Arguments
Close Object Type : Form
Object Name : Categories
Save : Prompt

 Save Macro edaydak;eQµaHfa McrClose


Prepared by Sann Sothearath 5
sMKal;³ kardak;eQµaHeGay Macro KYrdak;eGaycM²eRBaHeBleyIgman Form b¤
Table eRcInnwgman karRcbUkRcbl;eBlEdlbegáIt Macro eGayva.

 rebobP¢ab; Macro to Form


 ebIk Form Ca Design View (Form: Categories)

 cucelI Window Menu rYcyk Tile Horizontal

eBlEdl Form Design and Database Window bgáðajxøÜnTnÞwmKñaelI Screen cucelI


Macro Object kñúg Database Window rYccab;yk Macro eQµaH McrSuppliers (edaysgát;

Mouse eGayCab;) rYcGUsykeTAdak;kñúg Forms Rtg;kEnøgNamYysmKYr. bnÞab;mk cab;yk

Macro eQµaH McrClose eFVIdUcxagelI. eBlenaHeyIgnwg)an Button cMnYnBIr mYysMrab; Open

Table mYysMrab; Close Form Categories.

Prepared by Sann Sothearath 6


Creating Switchboard

Prepared by Sann Sothearath 7


Macro Group

Prepared by Sann Sothearath 8


Creating Dialog Box

Prepared by Sann Sothearath 9


rebobeFVI³
1- begáIt Form Customer Labels
2- cucelI Option Group Tool mkKUselIépÞ Form

Prepared by Sann Sothearath 10


3- sresrkñúg Label Name (dUcKMrUxagelI) rYccuc Next  Next  Next
4- eRCIserIsKMrUNamYyEdlGñkcg;)an rYccucelI Next button
5- vayBakü Print Labels For: enAkñúgRbGb;xagelI rYccucelI Finish

6- Select elIs‘umén Option Group  View  Properties

- All Rtg; Name sresr PrintLabelsFor

Prepared by Sann Sothearath 11


7- cucelI Combo box Tool mkKUskñúgs‘umén Option Group eRkam Specific Country
8- cucelI I want the combo box to look up the values in a table or query

9- cucelI Table: Customers rYccucelI Next


Prepared by Sann Sothearath 12
10- eRCIserIsykBakü Country rYccuc Next  Next  Next  Finish
11- Mouse sþaMelI Combo box yk Properties

- Rtg; Name dak;fa SelectCountry

- Rtg; Enable yk No

12- bnÞab;mkeyIgbegáIt Macro mYyeday Save dak;eQµaHfa Customer Labels Dialog

Prepared by Sann Sothearath 13


rYcerobcMdUcxageRkam³
Macro Name Condition Action Argument
Enable Select Country [PrintLabelsFor]=1 SetValue Item :[SelectCountry].[Enabled]
Expression : No
[PrintLabelsFor]=2 SetValue Item : [SelectCountry].[Enabled]
Expression : Yes
... GoToControl Control Name : SelectCountry
Preview [PrintLabelsFor]=1 OpenReport Report Name : Customer Labels
View : Print Preview
[PrintLabelsFor]=2 MsgBox Message : To preview or
IsNull([SelectCountry]) print labels, you
must either pick a
country from the
list or click All
Countries
... GoToControl Control Name : SelectCountry
... StopMacro

Prepared by Sann Sothearath 14


Macro Name Condition Action Argument
[PrintLabelsFor]=2 OpenReport Report Name : Customer Labels
View : Print Preview
Where Condition : [Country]=
[Forms] ![Customer
Labels Dialog]!
[SelectCountry]
Close Object Type : Form
Object Name : Customer Labels
Dialog
Save : Prompt

Cancel Close Object Type : Form


Object Name : Customer Labels
Dialog
Save : Prompt

Prepared by Sann Sothearath 15


13- cuc Mouse sþaMelIs‘umén Option Group yk Properties  Event
 Rtg;kEnøg After Update vayBakü Customer Labels Dialog.Enable SelectCountry

14- cucelI Command button rYcKUselIIépÞ Form

 Rtg; Name dak; Preview

 Rtg; Caption dak; Pre&view

 cuc Event

Prepared by Sann Sothearath 16


 Rtg;kEnøg On Click vayBakü Customer Labels Dialog.Preview
15- cucelI Command button rYcKUselIépÞ Form

 Rtg; Name dak; Print

 Rtg; Caption dak; &Print

 cuc Event

 Rtg;kEnøg On Click vayBakü Customer Labels Dialog.Cancel

Prepared by Sann Sothearath 17


 Rtg;kEnøg On Click vayBakü Customer Labels Dialog.Print
16- cucelI Command button rYcKUselIépÞ Form

 Rtg; Name dak; Cancel

 Rtg; Caption dak; Cancel

 cuc Event

Prepared by Sann Sothearath 18


Dialog Forms
eyIgeRbI Dialog Form sMrab;bBa©ÚltMélCalkçx½NÐedIm,IRsg;Tinnñ y½ (eyagtam
tMélEdleyIg)anbBa©Úlkñgú Dialog Form) enAeBlebI Form b¤ Report nwgGac
Print tamlkçx½NÐEdleyIgpþl;eGayva .

Prepared by Sann Sothearath 19


rebobeFVI³
 begáIt Forms “Dialog Form”

 cucelI Text box Tool mkKUsCa Text box cMnYnBIr mYysMrab; Enter

beginning date mYysMrab; Enter ending date

 erob Properties dUcxageRkam³

+ Text box Enter beginning date

- Rtg; Text lb;Bakünwgecal sresr Enter beginning date


- cuc Mouse xagsþaMelI Unbound yk Properties  All Rtg;

Name: sresr Enter beginning date


Prepared by Sann Sothearath 20
 Save Form dak;eQµaHfa Sales by Year Dialog
 begáIt Button OK and Cancel elI Dialog Form

- ebIk Dialog Form Ca Form Design View

- cucelI Command Button (biT Control Wizard) rYcmkKUrCa Button BIr mYy

sMrab; OK mYysMrab; Cancel rYcerob Properties dUcxageRkam ³


+ Button OK Rtg;

- Name sresr cmdok

- Caption sresr OK

- Control Tiptext sresr Click here to Open

(eGaybgðajBaküenHenAeBlyk Mouse Pointer eTAcg¥úlelIva)

Prepared by Sann Sothearath 21


-cucelI Event dak; Cursor Rtg; On Click rYccucelI yk Macro Builder 
OK  Save rYcerobdUcxageRkam³
Macro Name Action Action Arguments
OK OpenReport Report Name : Sale by Year
View : Print Preview
Filter Name :
Where Condition : [Orders]![OrderDate] Between
[Forms]![Sales by Year Dialog]! [BeginningDate] And
[Forms]![Sales by Year Dialog]![EndingDate]
Window Mode : Normal

Prepared by Sann Sothearath 22


+ Button Cancel Rtg;
- Name sresr cmdcancel

- Caption sresr Cancel

- Control Tiptext sresr Click here to Close

- cucelI Event dak; Cursor Rtg; On Click rYccucelI

yk Macro Builder  Ok Save rYcerobdUcxageRkam³

Prepared by Sann Sothearath 23


karbegáIt Shortcut Key
 kñúg Database Windows cucelI Macro Object  New
Macro Name Action Argument
^O OpenForm Form Name: Categories
 Save dak;eQµaHfa Autokeys
Keys List
Keys Syntax Key Combination

cMNaM³
^A Ctrl+A
 ^3 Ctrl+3

sBaØa (^) sMrab; Ctrl


{F1} F1
^{F1} Ctrl+F1

sBaØa (+) sMrab; Shift +{F1}


{INSERT}
Shift+F1
Ins
^{INSERT} Ctrl+Ins
{DELETE} or {DEL} Del
^{DELETE} or ^{DEL} Ctrl+Del
+{DELETE}or +{DEL} Shift+Del

Prepared by Sann Sothearath 24


Creating Find Record
eyIgeRbI Find Record edIm,IEsVgrkTinñn½yRKan; Et Select
elIelxkUd b¤eQµaHGVImYyenAeBlenH Find Record
nwgbgðajTinñn½yTaMgRsug.

Prepared by Sann Sothearath 25


rebobeFVI
1- ]bmafaeyIgman Table mYyeQµaH Customer

2- begáIt Form edayyk Field TaMgGs;BI Table Customer

3-ebIk Form Ca Design View

4- yk Mouse cucelI Combo box (biT Control Wizard) ykmk

KUrelI Form enAkEnøgNa mYysmKYr rYcerob Properties


dUcxageRkam³
- Name : Cust_ID
- Rowsource : Customer

Prepared by Sann Sothearath 26


5- cucelI Event Rtg; After Update: cucelI yk Macro
Builder
6- Save Macro dak;eQµaH Find Record rYcerobdUcxageRkam
Macro Name Action Argument
FindCust_ID GotoControl ControlName : CustomerID
FindRecord Findwhat : =[Cust_ID]

Prepared by Sann Sothearath 27


Creating Menu
File Edit Form Report
New Undo Categories Catalog
Open Find Customer Labels Dialog Customer Labels
Save Replace Customer Orders Invoice
Close New Record Customers
Exit Delete Record Employees

Prepared by Sann Sothearath 28


File Menu
 yk Mouse cucelI Macro tab  New  View  Macro Name
 erobcMdUcxageRkam
Macro Name Action Action Argument
&New RunCommand Command: NewDatabase
&Open RunCommand Command: OpenDatebase
&Save RunCommand Command: Save
&Close RunCommand Command: Close
&Exit RunCommand Command: Exit

 Save dak;eQµaH File  Close


Prepared by Sann Sothearath 29
Edit Menu
 yk Mouse cucelI Macro tab  New  View  Macro Name
 erobcMdUcxageRkam³
Macro Name Action Action Argument
&Undo RunCommand Command: Undo
&Find RunCommand Command: Find Next
&Replace RunCommand Command: Replace
&New Record RunCommand Command: RecordGotoNew
&Delete Record RunCommand Command: DeleteRecord

 Save dak;eQµaH Edit  Close


Prepared by Sann Sothearath 30
Form Menu
 yk cucelI
Mouse Macro tab  New  View  Macro Name

 erobcMdUcxageRkam³
Macro Name Action Action Argument
&Categories OpenForm Form Name: Categories
&Customer Labels Dialog OpenForm Form Name: Customer Labels Dialog
&Customer Orders OpenForm Form Name: Customer Orders
&Customers OpenForm Form Name: Customers
&Employees OpenForm Form Name: Employees

 Save dak;eQµaH Form  Close

Prepared by Sann Sothearath 31


Report Menu
 yk Mouse cucelI Macro tab  New  View  Macro Name
 erobcMdUcxageRkam³
Macro Name Action Argument
&Catalog OpenReport Report Name: Catalog
&Customer Labels OpenReport Report Name: Customer Labels
&Invoice OpenReport Report Name: Invoice

 Save dak;eQµaH Report  Close


Prepared by Sann Sothearath 32
Group Menu
 yk cucelI Mouse Macro tab  New  View  Macro Name

 erobcMdUcxageRkam³
Action Argument
Add Menu Menu Name :&File
Menu Macro Name :File
Add Menu Menu Name :&Edit
Menu Macro Name :Edit
Add Menu Menu Name :&Form
Menu Macro Name :Form
Add Menu Menu Name :&Report
Menu Macro Name :Report

 Save dak;eQµaH Menu  Close

Prepared by Sann Sothearath 33


P¢ab; Macro eTA Form
1- ebIk Form NamYyCa Form Design View
2- cucelI Edit  Select Form  View
 Properties
3- kñúg Other tab Rtg; Menu bar
vaybB©ÚalBakü Menu
4- ebIk Form Ca Form View

Prepared by Sann Sothearath 34


karRsg;Tinñn½ytamlMdab;GkSr

Prepared by Sann Sothearath 35


rebobeFVI³
1- begáIt Table Customer

2- begáIt Form Customer Phone List

3- ebIk Form Ca Design View rYcerob Properties dUcxageRkam

+cucelI Data tab Rtg;³

- Allow Deletions : No
- Allow Additions : No
+ cucelI Format tab Rtg;³
- Record Selectors : No
- Min Max button : No
Prepared by Sann Sothearath 36
4- cucelI Option Group (edaH Control Wizard ecj) ykmkKUselI Form Footer
rYccucelI View  Properties Rtg; Name vaybBa©ÚlBakü CompanyNameFilter
5- cucelI Toggle button mkKUskñúgsu‘m Option Group cMnYn 27

6- cucelI Toggle button TI1 Rtg;

- Name :A
- Caption : &A
- Option Value :1

7- eFVIdUcxagelIrhUtdl; button TI 27 Rtg; ³


- Name : All
- Caption : A&ll
- Option Value : 27

Prepared by Sann Sothearath 37


8- cuc Mouse xagsþaMelIs‘um Option Group rYcyk Properties  Event
Rtg; After Update cucelI yk Macro Builder  OK
9- Save Macro edaydak;eQµaHfa Filter rYcerobdUcxageRkam³
Condition Action
[CompanyNameFilters]=1 ApplyFilter
Action Argument
Where Condition: [CompanyName] Like "[AÀÁÂÃÄ]*"
Condition Action
[CompanyNameFilters]=2 ApplyFilter
Action Argument
Where Condition: [CompanyName] Like "B*"
Condition Action
[CompanyNameFilters]=3 ApplyFilter
Action Argument
Where Condition: [CompanyName] Like "[CÇ]*"
Condition Action
[CompanyNameFilters]=4 ApplyFilter
Action Argument
Where Condition: [CompanyName] Like "D*"
Prepared by Sann Sothearath 38
 eFVIdUcenHrhUtdl; Toggle button TI 27
Condition Action
[CompanyNameFilters]=27 ShowAllRecords

eRkam button TI27erobcMdUcxageRkam


Condition Action Action Argument
[CurrentRecord]>0 GoToControl Control Name: CompanyName
... StopMacro
[CurrentRecord]=0 MsgBox Message: There are no records for that letter
Beep : Yes
Type : Information
Titel : No Records Returned
... ShowAllRecords
... SetValue Item : [CompanyNameFilters]
Expression : 27
Prepared by Sann Sothearath 39
Prepared by Sann Sothearath 40

Вам также может понравиться