SETEC University Management Information System

Table of Contents Chapter 1 ...... 1 Introduction to MS-Access 2007 ...... 1 1.1. របបៀបបបើកកម្វម ធិ ី MS-Access 2007: ...... 1 1.2. របបៀបបិទកម្មវធីិ MS-Access 2007 ...... 3 1.3. របបៀបបប្កើត ថ្មី ...... 3 1.4. របបៀបបបើក Database ដែលមានស្រាប់ ...... 5 Chapter 2 ...... 6 Creating and Using ...... 6 2.1. របបៀបបប្កើត Table ថ្មីែំបូ្...... 6 2.2. របបៀបបប្កើត Table ថ្មីបដនែម្ ...... 7 2.3. របបៀបបប្កើត Table ថ្មីបដនែម្ បោយប្បើ Table Templates ...... 7 2.4. Field/ Table ...... 7 របបៀបបដនែម្ ចូលកុ្ន 2.5. Field/Column Table Field Templates ...... 7 របបៀបបដនែម្ ចូលកុ្ន បោយប្បើ 2.6. Field/Column Table Datasheet View: ...... 8 របបៀបបដនែម្ ពី បផេ្បទៀតកុន្ 2.7. Field/Column Table Datasheet View ...... 8 របបៀបលប់ បចញពី កុន្ 2.8. Table Design View ...... 9 របបៀបបប្កើត កុន្ 2.9. Primary Key: ...... 14 2.10. Import Table: ...... 14 2.11. Export Tables ...... 21 2.12. ភ្ជាប់បៅζន់ Table (Link Table): ...... 22 2.13. បប្កើត Lookup Wizard ...... 24 2.14. Relationships: ...... 30 2.15. ζរកំនត់ោក់ Password: ...... 33 Chapter 3 ...... 36 Creating and Using Query ...... 36 3.1. បប្កើត Select Query បោយប្បើ wizard: ...... 37 3.2. របបៀប Run query: ...... 39 3.3. Select Query Design View:...... 40 បប្កើត កុន្ 3.4. ζរ Backup Database ទុក: ...... 50 3.5. បប្កើត Delete Query: ...... 51 3.6. បប្កើត Update Query: ...... 53 3.7. បប្កើត Append Query: ...... 55 3.8. បប្កើត Make-table Query: ...... 57 3.9. បប្កើត Parameter Query: ...... 60 3.10. បប្កើត Crosstab Query: ...... 62 3.11. Structure (SQL): ...... 67

Table of Contents I Management Information System SETEC University Chapter 4 ...... 71 Creating and Using Form ...... 71 4.1. បប្កើត Form បោយប្បើ Form tool: ...... 71 4.2. របបៀប View form: ...... 72 4.3. បប្កើត Form បោយប្បើ Split Form tool ...... 74 4.4. បប្កើត Form បោយប្បើ Multiple Items tool: ...... 76 4.5. បប្កើត Form បោយប្បើ Wizard ...... 77 4.6. បប្កើត form បោយប្បើ Blank Form tool: ...... 79 4.7. ζររំកិល control បលើ form: ...... 81 4.8. ζរប្បើ្ាស់ form : ...... 82 4.9. បប្កើត Main form និ្ Subform ...... 83 4.10. Visual Basic for Application(VBA): ...... 89 4.11. Introduction to Variables: ...... 92 4.12. Data Type: ...... 93 4.13. Introduction to Procedures: ...... 100 4.14. Conditional Statements ...... 106 4.15. Counting and Looping Structures: ...... 107 4.16. Data Access Objects(DAO) ...... 109

Chapter 5 ...... 114 Creating and Using Report ...... 114 5.1. បប្កើត Report បោយប្បើ Report tool: ...... 114 5.2. របបៀប View Report ...... 114 5.3. បប្កើត Report បោយប្បើ Report Wizard ...... 117 5.4. បប្កើត Label បោយប្បើ Label Wizard ...... 121 5.5. បប្កើត Report បោយប្បើ Blank Report tool: ...... 124 5.6. អំពី Report Sections: ...... 125 5.7. បប្កើត Grouped Report ថ្មី បោយប្បើ Report Wizard: ...... 126 5.8. Homeworks ...... 132

II Table of Contents SETEC University Management Information System Chapter 1 Introduction to MS-Access 2007

Introduction

Microsoft Access 2007 Computer Application

desktop computer computer network ។

។ MS-Access 2007 ៖

- Table: (Store)

- Query: Tables

- Form: Table

- Report: ᾶដ ើម

1.1. MS-Access 2007:

- ១ : Start  (All) Program   Microsoft Office

Access 2007 ។

- ២ : Directory : C:\Program Files\Microsoft Office\Office12 

File msaccess.exe Double Click ។

- ៣ : Start Run  Open: msaccess Enter

OK ។

Chapter 1: Introduction to MS-Access 2007 Page 1 of 140 Management Information System SETEC University

MS-Access 2007

- Title bar: Office

Button Quick Access Toolbar ។ Quick Access Toolbar Title bar

Customized Button Office Button

- Office Button: Button (Save)

Database ។

- Quick Access Toolbar: Icons

Save, Undo Redo ។ Quick Access

Toolbar Customized Button Icons

Page 2 of 140 Chapter 1: Introduction to MS-Access 2007 SETEC University Management Information System

- The Work Area: MS-Access 2007

:

១ : Template Categories: (Categori s (Template)

២ : :

- (New Blank Database) Database ។

- (Featured Online Templates):

(Template) Database Microsoft ។

៣ :

1.2. MS-Access 2007

- Office Button  Exit Access

: Close Button Title bar

: Alt + F4

1.3. Datab s

- Office Button  New

: ១ (Template Categories)

Featuring  Blank Database

- File Name: Database

 Folder

- Save as type 2007 Database(*.accdb) 

Create ។

Chapter 1: Introduction to MS-Access 2007 Page 3 of 140 Management Information System SETEC University

Program Window MS-Access 2007 Ribbon

Navigation Pane Tabbed Documents

Status bar View Button

- The Ribbon: Program Window Commands

- Navigation Pane: objects

Database ។

- Tabbed Documents: Tables, Queries, Forms, Reports Macro

Tab ។

Page 4 of 140 Chapter 1: Introduction to MS-Access 2007 SETEC University Management Information System

- Status bar: Program Window

Buttons View ។

1.4. Databas

- Office Button  Open

: ៣ (Open recent document):

- Browse Database  Double-Click Database

Open ។

***End of Chaptert 1***

Chapter 1: Introduction to MS-Access 2007 Page 5 of 140 Management Information System SETEC University

Chapter 2 Creating and Using Table

诒វីដៅᾶ Table?

Table object MS-Access

2.1. T l

1. Database

2. Program Window :

Field/Column Headers

Row/Record Headers Tabbed document

3. Tabbed document, double-click Field/Column Headers

: Right-click Field/Column Headers  Rename column

4. Column  Tab

Field … Enter

5. Save Table  OK

Page 6 of 140 Chapter 2: Creating and Using Table SETEC University Management Information System

2.2. T l

1. Ribbon, Create  Icon: Table

2. Tabbed document, double-click Field/Column Headers

: Right-click Field/Column Headers  Rename column

3. Column  Tab

Field … Enter

4. Save Table  OK

2.3. T l Table Templates

1. Ribbon, Create  Icon: Table Templates

Templates

2. Save Table  OK

2.4. Fi l olumn Table

១ :

1. Table Datasheet View

2. Right-click Field/Column Header Column

3. Insert Column

២ :

1. Field/Column Header Column

2. Ribbon, Datasheet  Fields & Column, Icon: Insert

2.5. Fi l olumn T l Field

Templates

1. Table Datasheet View

2. Field/Column Header

Column

Chapter 2: Creating and Using Table Page 7 of 140 Management Information System SETEC University

3. Ribbon, Datasheet  Fields & Column, Icon: New Field

4. Field Templates, Fields

Table ។

2.6. Fi l olumn T l Datasheet View:

1. Table Datasheet View

2. Field/Column Header

Column

3. Ribbon, Datasheet  Fields & Column,

Icon: Add Existing Field

4. Field List, Fields

Table

2.7. Fi l olumn T l Datasheet View

១ :

1. Table Datasheet View

2. Right-click Field/Column Header Field

3. Delete Column  YES

២ :

1. Table Datasheet View

2. Field/Column Header Field

3. Ribbon, Datasheet  Fields & Column, Icon: Delete 

YES

Page 8 of 140 Chapter 2: Creating and Using Table SETEC University Management Information System

2.8. T l Design View

1. Ribbon, Create  Icon: Table Design

2. Field Name: Field Table

3. Data Type: user Field :

- Text: ២៥៥

- Memo: ៦៣ ។

support Rich Text Formatting ។

E.g: Property: Text Format = Rich Text)

- Number:

- Date/Time: ១

- Currency:

Chapter 2: Creating and Using Table Page 9 of 140 Management Information System SETEC University

- AutoNumber: user

record

- Yes/No: user (Yes/No,

True/False, or On/Off)

- OLE Object: Object (Files) word, excel, graphics,

sound

- Hyperlink: Text (Path/URL) File,

Web Page Website

- Attachment: (attach) images, word, excel

records Database

- Lookup Wizard: Field user

List Table List box Combo box

4. Description: Field Status bar

5. Field Properties: Fields

Page 10 of 140 Chapter 2: Creating and Using Table SETEC University Management Information System

Field Properties Data Type

Data Type Field Properties

Text - Field Size: user Field

- Format: Datasheet View

>:

<:

@[color]: E.g : @[red]/[black]/[blue]/[green]/[cyan]/[magenta]/[yellow]/[white]

- Input Mask: :

0 (zero): + -

9 (nine):

+ - ។

# : +

- ។ : Space user ។

L: A

? (Question mark): A

A:

a:

&: sp

C: sp

<:

>:

- Caption: Label Column Heading Datasheet Form

- Validation Rule: Field

- Validation Text: Text Message box

user Validation Rule

Chapter 2: Creating and Using Table Page 11 of 140 Management Information System SETEC University

Data Type Field Properties

- Required: - o Field

- Yes: Field

- Allow Zero Length:

- No: String Null string

- Yes: String Null string

- Indexed:

- No: The field is not indexed (default). index Field

- Yes(Duplicates OK): index Field user

- Yes(No Duplicates): index Field user

Number - Field Size:

- Byte: 1 byte of memory or disk space, holds from 0 to 255

- Integer: 2 bytes of storage, holds from -32,768 to 32,767

- Long Integer: 4 bytes of storage, holds from -2,147,483,648 to

2,147,483,647

38 - Single: 4 bytes of storage, holds from -3.402823x10 to

38 3.402823x10

308 - Double: 8 bytes of storage, holds from -1.79769313486232x10 to

308 1.79769313486232x10

- Format:

- 000: to put 00 left number E.g.: 001

- #,##0.00R: format Riel E.g.: 10,000.00R

Date/Time - Format:

- d: Display the day of the month as one or two digits.

- dd: Display the day of the month using two digits.

Page 12 of 140 Chapter 2: Creating and Using Table SETEC University Management Information System

Data Type Field Properties

- ddd: Display the first three letters of the day of the week.

- dddd: Display the full name of the day of the week.

- m: Display the month of the year as one or two digits.

- mm: Display the month of the year using two digits.

- mmm: Use the first three characters of the month.

- mmmm: Use the full name of the month.

- yy: Use the last two digits of the year.

- yyyy: Use the full year.

- h: Display the hour using one or two digits.

- hh: Display the hour using two digits.

- n: Display the minute using one or two digits.

- nn: Display the minute using two digits.

- s: Display the second using one or two digits.

- ss: Display the second using two digits.

- Input Mask:

- Date: 00/00/00

- Time: 00:00:00

E.g. 1 :

Input mask Sample values

(000) 000-0000 (206) 555-0248

(999) 999-9999 (206) 555-0248

( ) 555-0248

(000) AAA-AAAA (206) 555-TELE

#999 -20

2000

>L????L?000L0 GREENGR339M3, MAY R 452B7

Chapter 2: Creating and Using Table Page 13 of 140 Management Information System SETEC University

>L0L 0L0 T2F 8M4

00000-9999 98115-

98115-3007

>L

Brendan

SSN 000-00-0000 SSN 555-55-5555

>LL00000-0000 DB51392-0493

E.g. 2:

ValidationRule Property ValidationText Property

<> 0 Entry must be a nonzero value.

> 1000 Or Is Null Entry must be blank or greater than 1000.

Lik “A????" Entry must be 5 characters and begin with the letter "A".

2.9. Primary Key:

Primary Key Field (Records)

Table ។

 Field Primary Key:

1. Table Design View  Field Primary

Key

2. Ribbon, Tab: Design  Icon: Primary Key

 Primary Key Field:

1. Table Design View  Field Primary Key

2. Ribbon, Tab: Design  Icon: Primary Key

2.10. Import Table:

 Import Table Database

1. Database Import Table

Page 14 of 140 Chapter 2: Creating and Using Table SETEC University Management Information System

2. Ribbon, t “Ext rn l D t ”  Import: Access

Window :

3. Browse Database Tables

4. “Import T l s, qu ri s, forms, …”  OK

Window :

Chapter 2: Creating and Using Table Page 15 of 140 Management Information System SETEC University

5. “Import O j t”, tab: Tables  Tables

Import  OK

6. “S v import st ps”  Close

 Import Table File MS-Excel

1. Database Import Table

2. Ribbon, t “Ext rn l D t ”  Import:

Excel Window :

Page 16 of 140 Chapter 2: Creating and Using Table SETEC University Management Information System

Browse File MS-Excel Tables

3. “Import th sour t …”  OK

Window “Import Spr sh t Wiz r ” :

Chapter 2: Creating and Using Table Page 17 of 140 Management Information System SETEC University

4. “Show Worksh ts” List sheet

Import  Next window :

Page 18 of 140 Chapter 2: Creating and Using Table SETEC University Management Information System

5. “First ont ins olumn H ing” row ១

Column heading  Next window :

6. Field :

 Field Name: Field

 Data Type:

 Indexed: Index

 “Do not import fi l Skip ” Import

Field

7. Next window :

Chapter 2: Creating and Using Table Page 19 of 140 Management Information System SETEC University

8. :

 Let Access add primary key: Access primary key

 Choose my own primary key: Field primary key

 No primary key: primary key

9. Next window :

Page 20 of 140 Chapter 2: Creating and Using Table SETEC University Management Information System

10. Table Import “Import to T l ”  Finish

11. Close

2.11. Export Tables

 Export table File MS-Excel:

1. Navigation bar, table

Export

2. Ribbon, t “Ext rn l D t ”  Export:

Excel Window :

Chapter 2: Creating and Using Table Page 21 of 140 Management Information System SETEC University

3. Browse Export table 

options :

 Export data with formatting and layout: Export

format layout

 Open the destination file after the export operation is complete: file

export export

 Export only the selected records: Export records

4. OK  Close

2.12. Table (Link Table):

 Link Table Database :

1. Database Link table

2. Ribbon, tab: External Data 

Import, Icon: Access Window :

Page 22 of 140 Chapter 2: Creating and Using Table SETEC University Management Information System

3. Browse Database Link tables

4. “Link to th t sour …”  OK

Window :

5. “Link T l s”, Tables Link 

OK

Chapter 2: Creating and Using Table Page 23 of 140 Management Information System SETEC University

2.13. Lookup Wizard

 Lookup Wizard :

1. table Design View

2. Data type: Lookup Wizard Field Lookup

Wizard (E.g.: Sex)

3. win ow “Lookup Wiz r ” :

Page 24 of 140 Chapter 2: Creating and Using Table SETEC University Management Information System

4. “I will typ in th v lu s th t I w nt”  Next

window :

 Number of columns: columns

5. Col1, Lookup column (E.g.:

6. Next window :

7. lookup column  Finish

8. Save table

Chapter 2: Creating and Using Table Page 25 of 140 Management Information System SETEC University

 Lookup Wizard Tables/Queries :

1. table Design View

2. Data type: Lookup Wizard Field Lookup

Wizard win ow “Lookup Wiz r ” :

3. “I w nt th lookup olumn to look up th v lu s in t l or

qu ry”  Next

Page 26 of 140 Chapter 2: Creating and Using Table SETEC University Management Information System

4. table query Lookup

column  Next

5. Fields “Av il l Fi l s” Field

Lookup column  Next

6. sort order (Ascending/Descending) Fields 

Next

Chapter 2: Creating and Using Table Page 27 of 140 Management Information System SETEC University

7. column mouse (drag) column

 “Hi k y olumn r omm n ”

key column

8. Next

9. lookup column  Finish

10. + Yes: save table relationships

+ No: relationships Page 28 of 140 Chapter 2: Creating and Using Table SETEC University Management Information System

11. Save table

 lookup column Field

1. table Design View  Field lookup column

2. Field Properties, tab: Lookup  “Displ y

ontrol”, Text Box

3. Save table

Chapter 2: Creating and Using Table Page 29 of 140 Management Information System SETEC University

2.14. Relationships:

 Relationships:

1. Ribbon, tab: Database Tools 

Show/Hide, Icon: Relationships

Relation tab :

2. tab: Design Icon: Show Tables

: Right-click Relationship Window  Show Tables

“Show T l ” :

Page 30 of 140 Chapter 2: Creating and Using Table SETEC University Management Information System

3. tab: Tables  tables relationship 

Add

4. Close

5. Primary key (drag) Edit

Relationships :

Chapter 2: Creating and Using Table Page 31 of 140 Management Information System SETEC University

6. Create

7. tab: Design Icon: Close Relationship tab

 Relationship:

1. tab: Design Icon: Relationship

Relationship tie

2. Double-click Relationship tie

: Right-click Relationship tie  “E it R l tionship…”

Page 32 of 140 Chapter 2: Creating and Using Table SETEC University Management Information System

3. Relationship :

 Enforce :

Relationship Tables

 Cascade Update Related Fields: rim ry y

Foreign Key ។

 Cascade Delete Related Records:

Primary table Foreign table

4. OK

 Relationship:

1. tab: Design Icon: Relationship

2. Relationship tie  key: Delete

: Right-click Relationship tie  Delete

3. Yes

2.15. Password:

 Password Database:

1. database Exclusive Mode: Chapter 2: Creating and Using Table Page 33 of 140 Management Information System SETEC University

- Office Button  Open

- Database

Password  button:

Open  “Op n

Ex lusiv ”

Page 34 of 140 Chapter 2: Creating and Using Table SETEC University Management Information System

2. Ribbon, tab: Database Tools  Database Tools, Icon:

Encrypt with Password

3. Password:

 Password: Password

 Verify: Password

4. OK

 Password Database

1. database Exclusive Mode

2. Ribbon, tab: Database Tools 

Database Tools, Icon: Decrypt Database

3. Password  OK

Chapter 2: Creating and Using Table Page 35 of 140 Management Information System SETEC University

Chapter 3 Creating and Using Query

I. Query?:

Query object MS-Access

table tables ។ Query

។ Query

Form, Report Data

Access Page ។

Query MS-Access :

1. Select Query: u ry

table

។ Select Query

: Sum, Count, Average, Max in ។

2. Action Query: Query

t l s ។ Action Query

៤ :

- Delete Query : table

- Update Query : table

- Append Query : table table

- Make-table Query: table t l

3. Parameter Query: Query

4. Crosstab Query: Query

។ sum, average,

Page 36 of 140 Chapter 3: Creating and Using Query SETEC University Management Information System

ount,…

5. Structured Query Language (SQL): query

SQL Statement SQL Commands (SELECT,

UPDATE DELETE) , SQL Clauses (WHERE ORDER ។

SQL relational databases

Microsoft Access ។

II. Query:

3.1. S l t u ry wizard:

1. Ribbon, tab: Create  Other, Icon: Query

Wizard Win ow “ w u ry” :

2. “Simpl u ry Wiz r ”  OK

Chapter 3: Creating and Using Query Page 37 of 140 Management Information System SETEC University

3. “T l s u ri s”, Table 

List “Av il l Fi l s”, Fields Query

List “S l t Fi l s”

4. Next

5. “D t il shows v ry fi l of v ry r or ”  Next

Page 38 of 140 Chapter 3: Creating and Using Query SETEC University Management Information System

6. query  “Op n th qu ry to vi w inform tion” 

Finish

Lab 1: Create select query by using wizard:

1. t s “ orthwin . ”

2. Select Query table Products : ProductID, ProductName,

UnitPrice, UnitsInStock.

3. Save query “qry ro u ts”

Lab 2: Create select query by using wizard: (Modify the query design)

1. t s “ orthwin . ”

2. Select Query table Customers : CustomerID, ContactName,

Address, City, Phone

3. S v th qu ry s “qry ustom r ont t” n hoos “ o ify th qu ry sign”

3.2. Run query:

1. Ribbon, Query Tools: Design  Result, Icon: Run

Chapter 3: Creating and Using Query Page 39 of 140 Management Information System SETEC University

3.3. S l t u ry Design View:.

1. Ribbon, tab: Create  Other, Icon: Query

Design Win ow “Show T l ” :

2. tab: Tables  Tables 

Add  Close Query Window :

3. Double-click Field

: mouse Field (drag)

- Fi l table

- T l tables

Page 40 of 140 Chapter 3: Creating and Using Query SETEC University Management Information System

- Sort (Ascending/Descending).

- Show

- Criteria: ។

: >,

<, <=, >=, Is Null, Is Not Null, Between…An …, In, ot In, Lik , An , Or,<>,… ។

** Like: (wildcards) :

១ E.g. Lik “sm ”

? E.g. Lik “sm?th”

h r t r E.g. Lik “sm iy th”

E.g. Lik “sm i th”

-

E.g. Lik “ - ”

* Disable the output of all fields in query design:

- Office Button  Access Options Object Designer  “ u ry D sign”, uncheck  Output all fields

Chapter 3: Creating and Using Query Page 41 of 140 Management Information System SETEC University

Lab: Select Query Design View:

1. database: Northwind.accdb

2. Select Query table: Customers :

a. (Sort: Ascen ing

CompanyName ។

b. London

c. Fr ។

3. Select query table Products :

a. ៥ ។

b. ៣

t goryID=8 S foo ។

c. Chang Unit ri

$18.00 ។

4. Select query table Orders :

a. 12/11/1996

20/04/1997 ShipCountry=Germany ។

b. (ShipRegion) WA, CA, SP ។

c. (ShipRegion) ។

5. Select query t l ustom rs Orders

Homework

1. ProductName, UnitPrice CategoryName

(Categories) Seafood ។

2. ProductName, UnitPrice CategoryName

១ (Categories) Seafood ។

3. CategoryID, ProductName, UnitPrice UnitsInStock

“r” ៣ E.g: Norwood, Carnarvon,

Sir Ro n y, … ។ Page 42 of 140 Chapter 3: Creating and Using Query SETEC University Management Information System

E.g:

> 234 Returns all numbers greater than 234. To find all numbers less

than 234, use < 234.

>= "Cajhen" Returns all records from Cajhen through the end of the alphabet

Between #2/2/2007# Returns dates from 2-Feb-2007 through 1-Dec-2007 (ANSI-89). If

And #12/1/2007# your database uses the ANSI-92 wildcard characters, use single

quotation marks (') instead of pound signs (#). Example: Between

'2/2/2007' And '12/1/2007'

Not "Germany" Finds all records where the exact contents of the field are not

exactly equal to "Germany." The criterion will return records that

contain characters in addition to "Germany," such as "Germany

(euro)" or "Europe (Germany)".

Not "T*" Finds all records except those beginning with T. If your database

uses the ANSI-92 wildcard character set, use the percent sign (%)

instead of the asterisk (*).

Not "*t" Finds all records that do not end with t. If your database uses the

ANSI-92 wildcard character set, use the percent sign (%) instead

of the asterisk (*).

In(Canada,UK) In a list, finds all records containing Canada or UK.

Like "[A-D]*" In a Text field, finds all records that start with the letters A through

D. If your database uses the ANSI-92 wildcard character set, use

the percent sign (%) instead of the asterisk (*).

Like "*ar*" Finds all records that include the letter sequence "ar". If your

database uses the ANSI-92 wildcard character set, use the

percent sign (%) instead of the asterisk (*).

Chapter 3: Creating and Using Query Page 43 of 140 Management Information System SETEC University

Lik “ ison Finds all records that begin with "Maison" and contain a 5-letter

Dewe?" second string in which the first 4 letters are "Dewe" and the last

letter is unknown. If your database uses the ANSI-92 wildcard

character set, use the underscore (_) instead of the question mark

(?).

#2/2/2007# Finds all records for February 2, 2007. If your database uses the

ANSI-92 wildcard character set, surround the date with single

quotation marks instead of pound signs ('2/2/2007').

< Date() - 30 Uses the Date function to return all dates more than 30 days old.

Date() Uses the Date function to return all records containing today's

date.

Between Date() And Uses the Date and the DateAdd functions to return all records

D t A “ ", 3, between today's date and three months from today's date.

Date())

Is Null Returns all records that contain a (blank or undefined) value.

Is Not Null Returns all records that contain any value (that are not null).

“" Returns all records that contain a zero-length string. You use zero-

length strings when you need to add a value to a required field, but

you don't yet know what the actual value is. For example, a field

might require a fax number, but some of your customers might not

have fax machines. In that case, instead of entering a number, you

enter a pair of double quotation marks with no space between them

“" .

3.3.1. Alias field name: Field query

: NewFieldName : OldFieldName

E.g 1. : Name : FirstName Page 44 of 140 Chapter 3: Creating and Using Query SETEC University Management Information System

E.g 2. Full m First m & “ “ & L st m

E.g 3. : Sub Total : [UnitPrice]*[Quantity]

3.3.2. Aggregate function:

1. Select Query Design View

2. Ribbon, Query Tools: Design

3. Show/Hide, Icon: Total Total grid

:

Total grid

4. Total grid, Aggregate function fields :

Group y, Sum, ount, Avg, x, in, …

Chapter 3: Creating and Using Query Page 45 of 140 Management Information System SETEC University

5. Run

3.3.3. Expression Builder:

1. Select Query Design View

2. Field

3. Ribbon, Query Tools: Design  Query Setup, Icon: Builder

: Right-click Field  Builder

Page 46 of 140 Chapter 3: Creating and Using Query SETEC University Management Information System

4. Double-Click folder: Function  Built-In Function 

functions Double-click function

function function 5.  OK

6. Run query

Lab1: Select Query Aggregate function

1. database Northwind.accdb

2. Select Query table Products

a. Group by CategoryID

b. Sum on UnitsInStock

3. Save query “qryUnitsInSto k y t gory”

4. Run the query

Lab2: Calculation using Expression Builder

1. database Northwind.accdb

2. Select Query table OrderDetails fields: OrderID,

ProductID, UnitPrice, Quantity

3. field :

- SubTotal Before Discount: [UnitPrice]*[Quantity]

- Discount Price: [UnitPrice]*[Quantity]*Discount

Chapter 3: Creating and Using Query Page 47 of 140 Management Information System SETEC University

- SubTotal After Discount: [SubTotal Before Discount] – [Discount Price]

: SubTotal After Discount: [UnitPrice]*[Quantity]*(1-[Discount])

: SubTotal After Discount$: Format([UnitPrice]*[Quantity]*(1- Dis ount ,” urr n y”

4. S v qu ry s “qrySu Tot l”

3.3.4. Build-in Function - IIF: Function

: IIf(expression, truepart, falsepart)

expression:

truepart:

falsepart:

E.g.1 R sult IIf S or >=50,” ss ”,”F il ”

E.g.2 : Mention: IIf([TotalScore] Between 450 And 500,"Excellent",IIf([TotalScore]

Between 350 And 449,"Very Good",IIf([TotalScore] Between 200 And

349,"Good","Poor")))

E.g. 3 L ngu g IIf ountryR gion =“It ly”, “It li n", “Som oth r l ngu g "

E.g. 4: Status: IIf([Due Date]

Lab 1: Build-in function IIF

1. database Northwind.accdb

2. Select Query table Products : ProductID, ProductName,

UnitInStock

3. field StockStatus

UnitsInStock=0 “ ro u t out of sto k”

“ ro u t not out of sto k”

4. Save query “qrySto kSt tus”

Page 48 of 140 Chapter 3: Creating and Using Query SETEC University Management Information System

Lab: nested function IIF

1. database Northwind.accdb

2. Select Query table Products : ProductID, ProductName,

UnitsInStock, UnitPrice

3. field Mention

UnitPrice 1 - 20 ntion “V ry h p”

UnitPrice 21 - 50 ntion “ h p”

UnitPrice 51 - 70 ntion “Exp nsiv ”

UnitPrice > 70 ntion “V ry Exp nsiv ”

4. Save query “qry ro u t ntion”

3.3.5. Build-In-Function :

Abs(Number): Absolute value Chr(charcode): Convert ascii to character

Avg(expr): Average Asc(Strexpr): Convert character to ascii

CBool(expr): Convert to Boolean Date(): Display current date

CByte(expr): Convert to byte DateAdd(Interval,Number,Date): Add to

CCur(expr): Convert to currency date by interval

CDate(date): Convert to date DateDiff(Interval,Date1,Date2): Date2

CDbl(expr): Convert to double minus Date1 by interval

CInt(expr): Convert to integer DatePart(Interval,Date): Select date by

CLng(expr): Convert to long integer interval

* Interval : Year yy, yyyy

Quarter q, q

Month mm, m

Chapter 3: Creating and Using Query Page 49 of 140 Management Information System SETEC University

* Interval : Day dd, d

Week wk, ww

Hour hh

Minute mi, n

Second ss, s

Milisecond ms

Ex D t rt “yyyy”,D t

* Build-in functions - Date/Time

- DateAdd(Interval,Number,Date):

interval

E.g. : D t A “yyyy”,10, Hir D t

- DateDiff(Interval,Date1,Date2): Date2 Date1

interval

E.g. : D t Diff “yyyy”, irthD t , ow

- DatePart(Interval,Date):

interval

E.g. : D t rt “ ”, irthD t

D t rt “m”, irthD t

D t rt “yyyy”, irthD t

* Build-in functions - Format()

E.g. : Form t irthD t , “yyyy”

Form t Amount , “ urr n y”

Format([Amount], “៛ #,##0.00")

10 Year Aniversary: Format(DateAdd("m",10,[HireDate]),"dd/mmm/yy")

3.4. kup D t s :

1. Database file Back up

2. Office button  Manage  Back Up Database

Page 50 of 140 Chapter 3: Creating and Using Query SETEC University Management Information System

3. Save As dialog box, browse Database file

4. File name, Database file Back up

5. Save

3.5. Delete Query:

table ។

1. S l t u ry Design View

2. Ribbon, Query Tools: Design

3. Query Type, Icon: Delete Delete grid

:

Chapter 3: Creating and Using Query Page 51 of 140 Management Information System SETEC University

Delete grid

4. field record:

- Field: field

- Table: table

- Delete: + From: field table record

+ Where: field

5. Run the query

Page 52 of 140 Chapter 3: Creating and Using Query SETEC University Management Information System

6. Yes records

L D l t u ry :

1. records table: Order Details (UnitsInStock)

30 ។

2. table: Orders OrderID 10500 ។

3. table: Orders

ID = “ LAUS” ។

4. table: Products (CategoryName)

Seafood ។

3.6. Update Query:

table ។

1. S l t u ry Design View

2. Ribbon, Query Tools: Design

3. Query Type, Icon: Update Update grid

Chapter 3: Creating and Using Query Page 53 of 140 Management Information System SETEC University

Update grid

4. fields fields Update record

- Field: field Update record

- Table: table

- Update To:

- Criteria:

5. Run the query

Page 54 of 140 Chapter 3: Creating and Using Query SETEC University Management Information System

6. Yes

Lab: Update query

1. Country=“ xi o” “ m o i ” table: Customers

2. Update Unit ri t l ro u ts

១ stock

២ ។

3.7. Append Query:

record table ។

1. S l t u ry Design View Source table

2. Ribbon, Query Tools: Design

3. Query Type, Icon: Append

4. :

- T l m Destination table record

- Current Database: Database

- Anoth r D t s record table database

Chapter 3: Creating and Using Query Page 55 of 140 Management Information System SETEC University

5. OK  fields fields Append

- Field: Field Source table

- Table: Source table

- Append To: Field Destination table

- Criteria:

6. Run the query

7. Yes

Page 56 of 140 Chapter 3: Creating and Using Query SETEC University Management Information System

L r t App n u ry :

1. table Clients table: Customers

2. table Customers ountry=” xi o”

table Clients ។

3. table Customers fax

table Clients ។

4. table Customers

Germany table Clients ។

5. table Customers Canada UK

table Clients ។

E.g.:

< Date() - 30 Returns all dates more than 30 days old.

Betw n D t An D t A “ ", 3, D t Returns ll r or s tw n to y‘s date

and three months from today‘s date.

3.8. Make-table Query:

table t l

1. S l t u ry Design View tables

2. Ribbon, Query Tools: Design

3. Query Type, Icon: Make-table Query :

4. :

- T l m table record

Chapter 3: Creating and Using Query Page 57 of 140 Management Information System SETEC University

- Current Datab s table Database

- Anoth r D t s table database

5. OK

6. fields fields table

7. Run the query

8. Yes

Page 58 of 140 Chapter 3: Creating and Using Query SETEC University Management Information System

Lab: Make-table query :

1. database Northwind.accdb

2. t l CustomerAG fields: CustomerID, ContactName,

Address ity table: Customers ID

A G ។

3. t l ustom rLon on ri fields: CustomerID,

ContactName, Address ity table: Customers

London Madrid ។

4. t l ro u t otSE fields: ProductID, ProductName,

UnitPrice UnitsInStock table: Products

“s” “ ” ។

Chapter 3: Creating and Using Query Page 59 of 140 Management Information System SETEC University

3.9. Parameter Query:

Query

1. S l t u ry Design View tables

2. fields field Parameter

Query

3. Parameter Query Criteria field

E.g: Between [Start Date] And [End Date]

4. Run the query Parameter

Page 60 of 140 Chapter 3: Creating and Using Query SETEC University Management Information System

Lab: Create Parameter query

1. query table: Orders

(OderDate) (Begin Date End Date) ។

2. query table: Products

stock ។

3. query table: Customers

(CompanyName) ។

4. query table: Customers

omp ny m ។

Chapter 3: Creating and Using Query Page 61 of 140 Management Information System SETEC University

3.10. Crosstab Query:

Query

Column Heading

Row Heading

1. Ribbon, tab: Create  Other, Icon: Query Wizard

Win ow “ w u ry” :

2. “ rosst u ry Wiz r ”  OK

Page 62 of 140 Chapter 3: Creating and Using Query SETEC University Management Information System

3. table query Crosstab Query 

Next

4. field Row Heading  Next

Chapter 3: Creating and Using Query Page 63 of 140 Management Information System SETEC University

5. field Column Heading  Next

6. interval field Date/Time

Page 64 of 140 Chapter 3: Creating and Using Query SETEC University Management Information System

7. field function field 

Next

8. query  Finish

Chapter 3: Creating and Using Query Page 65 of 140 Management Information System SETEC University

Lab: Crosstab query:

1. database Northwind.accdb

2. crosstab query table Customers customers

ountry (City) ។

3. crosstab query table Orders

4. Wizard, crosstab query table: Orders Shippers

(Freight) (ShipCountry)

(CompanyName) ។

Page 66 of 140 Chapter 3: Creating and Using Query SETEC University Management Information System

3.11. Structure Query Language (SQL):

query SQL Statement

SQL Commands (SELECT, UPDATE DELETE), SQL CLAUSES (WHERE

ORDER ។ SQL

relational databases Microsoft Access ។

a) SQL:

1. Ribbon, tab: Create

2. Other, Icon: Query Design

3. Show Table, Close

4. Query Tools: Design  Result, Icon: SQL

Chapter 3: Creating and Using Query Page 67 of 140 Management Information System SETEC University

b) Run SQL:

- Ribbon, Query Tools: Design  Result, Icon:

Run

c) View SQL:

- Ribbon, tab: Home  View  SQL View

*** SELECT Statement

Instructs the Microsoft Jet database engine to return information from the database as a set of records.

Syntax :

SELECT [predicate] { * | table.* | [table.]field1 [AS alias1] [, [table.]field2 [AS alias2] [, ...]]}

FROM tableexpression [, ...] [IN externaldatabase]

[WHERE... ]

[GROUP BY... ]

[HAVING... ]

[ORDER BY... ]

[WITH OWNERACCESS OPTION]

Page 68 of 140 Chapter 3: Creating and Using Query SETEC University Management Information System

The SELECT statement has these parts:

Part Description

Predicate One of the following predicates: ALL, DISTINCT, DISTINCTROW, or

TOP. You use the predicate to restrict the number of records returned. If

none is specified, the default is ALL.

* Specifies that all fields from the specified table or tables are selected.

Table The name of the table containing the fields from which records are

selected. field1, field2 The names of the fields containing the data you want to retrieve. If you

include more than one field, they are retrieved in the order listed. alias1, alias2 The names to use as column headers instead of the original column

names in table. tableexpression The name of the table or tables containing the data you want to retrieve. externaldatabase The name of the database containing the tables in tableexpression if

they are not in the current database.

Lab: queries SQL Statement:

1. database Northwind.accdb

2. SQL :

a. ustom rID, ont t m A r ss t l ustom rs ។

b. ProductID, ProductName, UnitPrice UnitsInStock ១

UnitsInStock table: Products ។

c. ro u t m , Unit ri UnitsInSto k table: Products

stock ៥ (UnitPrice) ២ ។

d. Or rID, Or rD t , Fr ight Ship m table: Orders

(Freight) ៣ ៤ ។

e. L st m First m table: Employees sort

Descending LastName ។

Chapter 3: Creating and Using Query Page 69 of 140 Management Information System SETEC University

f. ២

table: [Order Details] ។

g. t l Or rs ។

h. OrderID,

១ Group by: OrderID t l Or r D t ils ។

i. Sort: Ascending

CompanyName ។

j. ustom rID, ont t m omp ny m

Subquery ។

k. ContactName, Address Country table: Customers, order by

Country, ContactName ។

*****End of Chapter 3*****

Page 70 of 140 Chapter 3: Creating and Using Query SETEC University Management Information System

Chapter 4 Creating and Using Form

诒វីដៅᾶ Form?

Form Object MS-Access interface

table query ។

4.1. Form Form tool:

1. Navigation Pane, table query Form

2. Ribbon, tab: Create  Form, icon: Form

3. Access form Layout view :

Chapter 4: Creating and Using Form Page 71 of 140 Management Information System SETEC University

4. Save save form

5. OK

4.2. View form:

1. Navigation Pane, Double-click form form

view Form View:

Page 72 of 140 Chapter 4: Creating and Using Form SETEC University Management Information System

2. Ribbon, tab: Home  Views, icon: View

: icons Status bar

- Form View: user ។

Chapter 4: Creating and Using Form Page 73 of 140 Management Information System SETEC University

- Layout View: form (formatting)

- Design View: form (formatting)

Layout View ។

4.3. Form Split Form tool

1. Navigation Pane, table query Form

Page 74 of 140 Chapter 4: Creating and Using Form SETEC University Management Information System

2. Ribbon, tab: Create  Forms, icon: Split Form

3. Access form Layout View :

Form View

Datasheet View

Chapter 4: Creating and Using Form Page 75 of 140 Management Information System SETEC University

4.4. Form Multiple Items tool:

1. Navigation Pane, table query Form

2. Ribbon, tab: Create  Form, icon: Multiple Items

3. Access form Layout View :

Page 76 of 140 Chapter 4: Creating and Using Form SETEC University Management Information System

4.5. Form Wizard

1. Ribbon, tab: Create  Form, More Forms 

Form Wizard

2. Wizard :

3. “T l s u ri s” , t l query

4. List “Av il l Fi l s”, fi l s form 

Next

Chapter 4: Creating and Using Form Page 77 of 140 Management Information System SETEC University

5. layout form olumn r, T ul r, D t sh t, … 

Next

6. style form Access 2003, Access 2007, Apex, ... 

Next

Page 78 of 140 Chapter 4: Creating and Using Form SETEC University Management Information System

7. form title bar  “Op n th form to vi w or nt r

information.” Finish

4.6. form Blank Form tool:

1. Ribbon, Create  Forms, icon: Blank Form

2. Layout View Field List pane

:

Chapter 4: Creating and Using Form Page 79 of 140 Management Information System SETEC University

3. Field List pane, (+) table fields

table

4. Double-click field form ។

fields key: Ctrl +

fields ។

5. tools Control tab: Format Logo, ,

form

Page 80 of 140 Chapter 4: Creating and Using Form SETEC University Management Information System

6. control form:

- Design view Right-click form  Design View

- Ribbon, tab: Design  tools Controls

4.7. control form:

1. form Design View  control

2. Right-click control  Layout 

Remove

3. Mouse pointer Controls

Chapter 4: Creating and Using Form Page 81 of 140 Management Information System SETEC University

4. Control Mouse pointer

Controls

4.8. form :

Cursor field field

- Tab: field

- Shift + Tab: Cursor

- Ctrl + Home: Cursor record ១ Form

- Ctrl + End: Cursor record Form

Page 82 of 140 Chapter 4: Creating and Using Form SETEC University Management Information System

4.9. Main form Subform

Main form Subform

tables One-to-Many ។ Main form

table One Subform

table Many ។

Main form Columnar Form Subform Tabular

Form Datasheet Form

 form Subform Form Wizard

1. Ribbon, tab: Create  Forms, icon: More Forms  Form

Wizard

2. window Form Wizard :

3. Tables/Queries, table/query Main form

4. Double-click fields Main form

5. Wizard Tables/Queries,

table/query Subform

6. Double-click fields Subform

Chapter 4: Creating and Using Form Page 83 of 140 Management Information System SETEC University

7. Next

8.  “Form

with su form s ”

9. Next

Page 84 of 140 Chapter 4: Creating and Using Form SETEC University Management Information System

10. layout subform : Tabular Datasheet

11. Next

12. style  Next

Chapter 4: Creating and Using Form Page 85 of 140 Management Information System SETEC University

13. Main form Subform  “Op n th form to vi w

or nt r inform tion”

14. Finish

 Subform form

1. Main form Columnar

Page 86 of 140 Chapter 4: Creating and Using Form SETEC University Management Information System

2. Subform Tabular Form Datasheet Form

3. View main form Design View

4. Ribbon, tab: Design  Controls, icon: Use Control

Wizards

5. Navigation Pane, Subform Detail Main

form design

Chapter 4: Creating and Using Form Page 87 of 140 Management Information System SETEC University

6. Access Subform Main form Relationship

Database ។

*** Access Subform Main form :

1. Navigation Pane, Right-click Main form  Design

2. form design, Subform

3. Ribbon, tab: Design Form Design Tools

 Tools, icon: Property Sheet

4. Property Sheet, tab: Data Properties

- Source Object: form Subform

Page 88 of 140 Chapter 4: Creating and Using Form SETEC University Management Information System

- Linked Master Field: Field (Primary key) Main form

Subform

- Linked Child Field: Field (Foreign key) Subform

Main form

5. View form Form View

Lab: Create Main form and Subform

1. Main form table: Customers

2. Subform table: Orders

3. Subform Main form

4.10. Visual Basic for Application(VBA):

V A Microsoft Visual Basic code

Windows

Application Microsoft ។

a. What is Object?

Object … ។

MS-Access Form, Object Control

Chapter 4: Creating and Using Form Page 89 of 140 Management Information System SETEC University

- Text Box : Control

keyboard

- Label : Control Control

- Command Button : Control button

event

- h k ox Control check

uncheck

- Option Button : Control

ន ។

a.1. What is Property?

Property Object Control Form MS-

Access ។ rop rti s ontrols form

.Left : form

.Top : form

.Height: Control

.Width: Control

a.2. What is Method?

Method object ។

ObjectName.MethodName

E.g. : txtFirstName.SetFocus Me!txtLastName.Undo rs.MoveNext rs.MoveFirst

a.3. What is Event?

Event (Procedure)

user program code ។

E.g.: Private Sub btnOK_Click() Statements… End Sub

Page 90 of 140 Chapter 4: Creating and Using Form SETEC University Management Information System Private Sub Form_Load() Statements… End Sub

Private Sub txtFirstName_GotFocus() Statements… End Sub

b. form Design view

Ribbon, Tab: Create  Form Design

c. Code vi w o form

View form Design View  Form Design Tools, Tab: Design 

View Code

d. event control

Click control  Property windows, tab: Event 

event button

: Right-click control  uil Ev nt… Code Builder  OK

Lab: Form Code

1. Form

txtFirstName txtLastName txtAddress btnClear

btnOK

2. Code Editor, code Private Sub btnOK_Click() txtFirstName.Value = "Sabay" txtLastName.Value = "Sok" txtAddress.Value = "Bokor mountain" End Sub Private Sub btnClear_Click() txtFirstName.Value = "" txtLastName.Value = "" txtAddress.Value = "" txtFirstName.SetFocus End Sub Chapter 4: Creating and Using Form Page 91 of 140 Management Information System SETEC University

4.11. Introduction to Variables:

Variable memory

application ។ variable

memory ។

E.g.1: Private Sub Detail_Click() SomeColor = vbRed Detail.BackColor = SomeColor End Sub

- (declare) variable Dim

variable ។

Dim VariableName

E.g.: Private Sub Form_Load() Dim thisVar thisVar = 15 MsgBox thisVar End Sub

- Option Explicit: variable

(Error) ។

E.g.: Private Sub Form_Load() Dim thisVar thisVar = 15 MsgBox thisInt '<-- Note the misspelled "thisInt"

End Sub

Option Explicit

Code Builder variable

variable ។

E.g. : Option Explicit Private Sub Form_Load() ..... End Sub

Page 92 of 140 Chapter 4: Creating and Using Form SETEC University Management Information System

- Option Explicit Code Builder:

1. menu Microsoft Visual Basic, Tools  Option…

2. tab: Editor  Code Settings, check h k ox “

R quir V ri l D l r tion”

4.12. Data Type:

Data Type variable ។ Dim VariableName As DataType

Or: Dim VariableName1 As DataType1, VariableName2 As DataType2 Dim VariableName3 As DataType3

Dim StudentName As Byte E.g. : Dim CountryName As String

- : Data Description Range) Type ( Byte 1-byte binary data (0 to 255)

Integer 2-byte integer (– 32,768 to 32,767)

Long 4-byte integer (– 2,147,483,648 to 2,147,483,647)

– 3.402823E38 to – 1.401298E 4-byte floating- ( Single point number – 45 (negative values)) 1.401298E – 45 to 3.402823E38 (positive values)

(– 1.79769313486231E308 to 8-byte floating- Double – 4.94065645841247E – 324 (negative values)) point number 4.94065645841247E – 324 to 1.79769313486231E308 (positive values) 8-byte number – 922,337,203,685,477.5808 to Currency with fixed decimal ( point 922,337,203,685,477.5807) String of Zero to approximately two billion String ( characters characters) 8-byte date/time January 1, 100 to Date ( value December 31, 9999)

- variable (Prefix)

variable

Chapter 4: Creating and Using Form Page 93 of 140 Management Information System SETEC University

Data Type Prefix Example

Boolean bln blnFound

Byte byt bytTracks

Date/Time dtm dteStartOfShift

Double dbl dblDistance

Error err errCantOpen

Integer int intNbrOfStudents

Long lng lngPopulation

Object obj objConnection

Single sng sngAge

String str strCountryName

Currency cur curHourlySalary

Variant var varFullName

- Functions

CBool(): convert Boolean Lng convert Long

CStr(): convert String CSng convert Single

CByte(): convert Byte CDbl: convert Double

(Small number) ur convert Currency

Int convert Integer D t convert Date

- Constant: variable ។

Const VariableName = Value

E.g. : Const conPI = 3.14159265359

vbCrLf (Carriage Return-Line Feed Constant) : constant

text ។

- Static keyword variable function

sub procedure ។ variable keyword:

Static memory

function sub procedure ។

Page 94 of 140 Chapter 4: Creating and Using Form SETEC University Management Information System Sub Calculate() E.g. : Static intVar As Integer intVar = intVar + 1 MsgBox intVar End Sub

Private Sub btnCalculate_Click() Call Calculate End Sub

Lab: Data Type:

1. form Design View

2. form  Property windows, tab: Event  event

“On li k” button

3. code Private Sub Detail_Click() Dim strName As String,intYearBorn As Integer Dim intAge As Integer strName = InputBox("Your name: ") intYearBorn = InputBox("Year borned: ") intAge = Format(Now(), "yyyy") - intYearBorn MsgBox "Hello " & strName & vbCrLf & _ "you are " & intAge & " years old." End Sub

4. form Design View A ontrol omm n utton :

- Caption: Calculate

- Name: btnCalculate

5. code Sub Calculate() Static intVar As Integer intVar = intVar + 1 MsgBox intVar End Sub

- event: On Click button: Calculate code: Private Sub btnCalculate_Click() Call Calculate End Sub

6. Save form “frmSt ti V ri l ”

Chapter 4: Creating and Using Form Page 95 of 140 Management Information System SETEC University

*** MsgBox function: (See help: MsgBox Function)

message dialog box click button user

constant button user click ។ MsgBox(prompt[, buttons Or icon] [, title])

title

icon prompt

buttons

- prompt: string expression message dialog

box ។

- button: buttons prompt Constant Value Description

vbOKOnly 0 Display OK button only.

vbOKCancel 1 Display OK and Cancel buttons.

vbAbortRetryIgnore 2 Display Abort, Retry, and Ignore buttons.

vbYesNoCancel 3 Display Yes, No, and Cancel buttons.

vbYesNo 4 Display Yes and No buttons.

vbRetryCancel 5 Display Retry and Cancel buttons.

vbCritical 16 Display Critical Message icon.

vbQuestion 32 Display Warning Query icon.

vbExclamation 48 Display Warning Message icon.

vbInformation 64 Display Information Message icon.

vbDefaultButton1 0 First button is default.

vbDefaultButton2 256 Second button is default.

vbDefaultButton3 512 Third button is default.

vbDefaultButton4 768 Fourth button is default.

Constants VBA constants

code ។

Page 96 of 140 Chapter 4: Creating and Using Form SETEC University Management Information System

If the user click The function returns Numeric Value

vbOK 1

vbCancel 2

vbAbort 3

vbRetry 4

vbIgnore 5

vbYes 6

vbNo 7

- titl string Title bar Message Box ។

E.g. : Private Sub Detail_Click() MsgBox "Do you really want to delete this record?", _ vbYesNoCancel Or vbQuestion, "Confirmation" End Sub

- buttons

MsgBox Dim x As Integer

x = MsgBox("Do you really want to delete this record?", _ vbYesNoCancel + vbQuestion, "Confirmation")

code MsgBox buttons

Yes, No Cancel ។ button: Yes

constant vbYes=6 x ។

*** InputBox Function:

message dialog box text click button user string text box ។

InputBox(prompt[, title] [, default])

Chapter 4: Creating and Using Form Page 97 of 140 Management Information System SETEC University

- prompt title: Message Box ។

- f ult text text box user

E.g. : Private Sub Form_Load() Dim x As Integer, y As Integer Dim sum As Integer x = InputBox("Please enter value of x", "Enter value of x") y = InputBox("Please enter value of y", "Enter value of y") sum = x + y MsgBox "The sum of " & x & " and " & y & " is " & sum, ,"Result" End Sub

Page 98 of 140 Chapter 4: Creating and Using Form SETEC University Management Information System

Lab : Form Code:

1. form

- Add buttons properties

Name Caption Events

btnSum Sum On_Click

btnSubtract Subtract On_Click

btnMultiply Multiply On_Click

btnDivide Divide On_Click

- click buttons , access InputBox user

(x y) ។

2. code Option Compare Database Option Explicit Private Sub btnDivide_Click() Dim x As Integer, y As Integer Dim divide As Integer x = InputBox("Please enter value of x", "Enter value of x") y = InputBox("Please enter value of y", "Enter value of y") divide = x / y MsgBox "The division of " & x & " and " & y & " is " & _ divide, , "Result" End Sub Private Sub btnMutiply_Click() Dim x As Integer, y As Integer Dim multiply As Integer x = InputBox("Please enter value of x", "Enter value of x") y = InputBox("Please enter value of y", "Enter value of y") multiply = x * y MsgBox "The multiplication of " & x & " and " & y & " is " & multiply, , "Result" End Sub

Chapter 4: Creating and Using Form Page 99 of 140 Management Information System SETEC University Private Sub btnSubtract_Click() Dim x As Integer, y As Integer Dim subtract As Integer x = InputBox("Please enter value of x", "Enter value of x") y = InputBox("Please enter value of y", "Enter value of y") subtract = x - y MsgBox "The subtract of " & x & " and " & y & " is " & subtract, , "Result" End Sub Private Sub btnSum_Click() Dim x As Integer, y As Integer Dim sum As Integer x = InputBox("Please enter value of x", "Enter value of x") y = InputBox("Please enter value of y", "Enter value of y") sum = x + y MsgBox "The sum of " & x & " and " & y & " is " & sum, , "Result" End Sub

4.13. Introduction to Procedures:

Procedure code program

។ ro ur s VBA Sub

Procedure Function Procedure ។ procedures Function

Procedure return Sub Procedure return

(Call) ។

4.13.1. Sub Procedure: Sub ProcedureName([Arguments]) Statements… End Sub

E.g. : Sub Multiply() Dim x As Integer, y As Integer Dim result As Integer x = txtValue1 y = txtValue2 result = x * y txtResult = result End Sub

- (Call) Sub Procedure Call ProcedureName([Arguments]) ProcedureName [Arguments]

Page 100 of 140 Chapter 4: Creating and Using Form SETEC University Management Information System

E.g. : Private Sub btnCalculate_Click() Call Multiply End Sub

- Sub Procedure Arguments Sub Multiply(x As Integer, y As Integer) Dim result As Integer result = x * y txtResult = result End Sub Private Sub btnCalculate_Click() Call Multiply(txtValue1, txtValue2) End Sub

4.13.2. Function Procedure: Function FuntionName([Arguments]) As DataType Statements… End Function

- Function Procedure Sub Procedure return

As DataType

return ។

E.g. : Function Divide() As Integer Dim x As Integer, y As Integer x = txtValue1 y = txtValue2 Divide = x / y End Function

- Function Procedure ។

statements Sub Procedure Sub

Procedure ។ return text box

variable ។

E.g. : Private Sub btnCalculate_Click() txtResult = Divide End Sub

Chapter 4: Creating and Using Form Page 101 of 140 Management Information System SETEC University

Lab: Sub Procedure:

1. form

2. Sub Procedure

3. Sub Procedure

4. click button: Calculate ។

5. click button: New clear text box ។

Sub SquareSolution() Dim dblSide As Double Dim dblPerimeter, dblArea As Double

dblSide = txtSide dblPerimeter = dblSide * 4 dblArea = dblSide * dblSide txtSqPerimeter = dblPerimeter txtSqArea = dblArea End Sub

Private Sub RectangleSolution() Dim dblLength, dblHeight As Double Dim dblPerimeter, dblArea As Double

dblLength = txtLength dblHeight = txtHeight dblPerimeter = (dblLength + dblHeight) * 2 dblArea = dblLength * dblHeight txtRecPerimeter = dblPerimeter txtRecArea = dblArea End Sub

Page 102 of 140 Chapter 4: Creating and Using Form SETEC University Management Information System

Private Sub btnCalculateRec_Click() RectangleSolution End Sub Private Sub btnCalculateSqare_Click() Call SquareSolution End Sub Private Sub btnSqNew_Click() txtSide = "" txtSqPerimeter = "" txtSqArea = "" txtSide.SetFocus End Sub Private Sub btnRecNew_Click() txtLength = "" txtHeight = "" txtRecPerimeter = "" txtRecArea = "" txtLength.SetFocus End Sub

Homework: Function Procedure:

Lab Function Procedure ។

4.13.3. Procedure Arguments:

- Sub ProcedureName(Var1 As Datatype, Var2 As Datatype,…)

Statements End Sub Function FunctionName(Var1 As Datatype, Var2 As Datatype,…) _ As Datatype Statements End Function

E.g. 1 Function Procedure ។ Function CubeArea(Side As Double) As Double CubeArea = Side * Side * 6 End Function

Function CubeVolume(Side As Double) As Double CubeVolume = Side * Side * Side End Function

- Call Function ro ur Arguments Private Sub btnCalculate_Click() txtArea = CubeArea(txtSide) txtVolume = CubeVolume(txtSide) End Sub Parameter

Chapter 4: Creating and Using Form Page 103 of 140 Management Information System SETEC University

Lab: Procedures with Arguments:

1. Sub Procedure Sub SolveEllipse(SmallRadius As Double, LargeRadius As Double) Dim dblCircum As Double Dim dblArea As Double

dblCircum = (SmallRadius + LargeRadius) * 2 dblArea = SmallRadius * LargeRadius * 3.14159 ‘2R

txtEllipseCircumference = dblCircum txtEllipseArea = dblArea End Sub

2. Function Procedures

Function BoxArea(dblLength As Double, _ dblHeight As Double, _ dblWidth As Double) As Double Dim Area As Double

Area = 2 * ((dblLength * dblHeight) + _ (dblHeight * dblWidth) + _ (dblLength * dblWidth) _ ) BoxArea = Area End Function

Function BoxVolume(dblLength As Double, _ dblHeight As Double, _ dblWidth As Double) As Double Dim Volume As Double Volume = dblLength * dblHeight * dblHeight BoxVolume = Volume End Function

Homework

HW1: Sub Procedure

១ HourW g ។

txtHours txtHWage txtResult btnE&xit

Page 104 of 140 Chapter 4: Creating and Using Form SETEC University Management Information System

Private Sub txtResult_GotFocus() Dim dblHours As Double Dim dblHWage As Double dblHours = txtHours dblHWage = txtHWage

CalcAndShowSalary dblHours, dblHWage End Sub

Sub CalcAndShowSalary(Hours As Double, HWage As Double) Dim dblResult As Double

dblResult = Hours * HWage txtResult = dblResult End Sub

Private Sub btnExit_Click() DoCmd.Close End Sub

HW2: Function Procedure discount

(Marked Price) (Discount Rate) ។

Function CalculateNetPrice(DiscountRate As Double) As Currency Dim OrigPrice As Double

OrigPrice = CCur(txtMarkedPrice) CalculateNetPrice = OrigPrice - OrigPrice * DiscountRate End Function

Private Sub cmdCalculate_Click() Dim dblDiscount Double

dblDiscount = CDbl(txtDiscountRate) txtNetPrice = CalculateNetPrice(dblDiscount) End Sub

Chapter 4: Creating and Using Form Page 105 of 140 Management Information System SETEC University

4.14. Conditional Statements

- Here is a summary table of the logical operators we have studied:

Operator Meaning Example Opposite

= Equality to a = b Not

Not Not equal to 12 <> 7 =

< Less than 25 < 84 >=

<= Less than or equal to Cab <= Tab >

> Greater than 248 > 55 <=

>= Greater than or equal to Val1 >= Val2 <

- The If…Then Statement If Condition Then Statement

: If Condition Then Statement1 Statement2 ……………… End If

- The If…Then…Else Statement If Condition Then Statement1 Else Statement2 End If

- The If…Then…ElseIf Statement If Condition1 Then Statement1 Else If Condition2 Then Statement2 Else If Condition3 Then Statement3 Else Statement4 End If

Page 106 of 140 Chapter 4: Creating and Using Form SETEC University Management Information System

Lab: Conditional Statements:

1. Password Form frmLogin

Textboxs:

- txtUserName

- txtPassword, Inputmask: Password

Command buttons:

- btnLogin, Caption: L&ogin

- btnClose, Caption: &Close

2. code event On_Click button: Login Private Sub btnLogin_Click() If txtUserName = "Sabay" And txtPassword = "1234" Then MsgBox "Welcome to my application" DoCmd.OpenForm "frmHourWage" Else txtPassword = "" txtUserName = "" txtUserName.SetFocus End If End Sub

3. code event On_Click button: Login Private Sub btnClose_Click() DoCmd.Close End Sub

4.15. Counting and Looping Structures:

Looping Structures computer

(Statements) ។

- Th Do Whil …Loop Do While Condition Statement(s) Loop

Chapter 4: Creating and Using Form Page 107 of 140 Management Information System SETEC University Private Sub cmdCounter_Click() E.g.: Dim Number As Integer Do While Number < 46 MsgBox CStr(Number) Number = Number + 4 Loop

MsgBox "Counting Stopped at " & CStr(Number) End Sub

- Th Do…Loop Whil Do Statement(s) Loop While Condition Private Sub cmdCounter_Click() E.g.: Dim Answer As String Do Answer = CStr(InputBox("Are we there yet(1=Yes/0=No)?", "Counter", "1")) Loop While Answer <> "1" MsgBox "Wonderful, we have arrived" End Sub

- Th Do Until…Loop Do Until Condition Statement(s) Loop

E.g.: Private Sub cmdCounter_Click() Dim Answer As String

Do Until (Answer = "1") Answer = InputBox("Are we there yet (1=Yes/0=No)?", _ "Counter", "1") Loop

MsgBox "Wonderful, we have arrived" End Sub

- Th Do…Loop Until Do Statement(s) Loop Until Condition

- Th For… ext: For Counter = Start To End Step Increment Statement(s) Next Counter

Note: To stop an endless loop, press ESC or CTRL+BREAK. Page 108 of 140 Chapter 4: Creating and Using Form SETEC University Management Information System

4.16. Data Access Objects(DAO)

1. What is DAO?

DAO Programming interface Microsoft Visual Basic

database Microsoft Microsoft Access database ។

2. Recordset

object DAO records table

query database ។

3. Database Object :

Dim DatabaseName AS DAO.Database

E.g. : Dim db AS DAO.Database

4. Recordset Object :

Dim RecordsetName AS DAO.Recordset

E.g. : Dim rs AS DAO.Recordset

5. Database Object :

Set db = CurrentDb() : Database Object ដ ើមបីភ្ជាប់ Database

Set db = DAO.OpenData s “ th\Fil m .m ” Database Object

Database ។

E.g. :

Set db = DAO.OpenDatab s “D \My Databases\StudentDB.acc ”

6. Recordset Object

S t rs = .Op nR or s t “T l |qu ry”, R or Typ

*RecordType:

- dbOpenDynaset: Open in Dynaset

- dbOpenTable: Open in table (have index)

- dbOpenSnapShot: Open in snapshot (read only)

Chapter 4: Creating and Using Form Page 109 of 140 Management Information System SETEC University

Lab1: DAO Form :

- Form :

txtSubjectID txtSubjectName txtDescription

btnLast btnNext btnPrevious

btnFirst - Database Recordset : Option Explicit Dim db As DAO.Database Dim rs As DAO.Recordset

Sub showDT() txtSubjectID.Value = rs.Fields("SubjectID") txtSubjectName.Value = rs.Fields("SubjectName") txtDescription.Value = rs.Fields("Description") End Sub

- Database Recordset Form_Load() : Private Sub Form_Load() Dim strSQL As String strSQL = "Select * from tblSubjects" Set db = CurrentDb Set rs = db.OpenRecordset(strSQL) Call showDT End Sub

- code btnFirst (event: On_Click) record ១: Private Sub btnFirst_Click() rs.MoveFirst Call showDT End Sub

- code btnLast (event: On_Click) record : Private Sub btnLast_Click() rs.MoveLast Call showDT End Sub

Page 110 of 140 Chapter 4: Creating and Using Form SETEC University Management Information System

- code btnNext (event: On_Click) record : Private Sub btnNext_Click() rs.MoveNext If Not rs.EOF Then Call showDT Else MsgBox "No more record" rs.MovePrevious End If End Sub

- code btnPrevious (event: On_Click) record : Private Sub btnPrevious_Click() rs.MovePrevious If Not rs.BOF Then Call showDT Else MsgBox "First record reached" rs.MoveNext End If End Sub

Lab 2: records :

btnSearch btnClear

- code btnSearch (event: On_Click) records: Private Sub btnSearch_Click() Dim strCriteria As String strCriteria = "Select * from tblSubjects Where _ SubjectName='" _ & InputBox("Input SubjectName:") & "'" Set db = CurrentDb Set rs = db.OpenRecordset(strCriteria)

If rs.EOF Then MsgBox "No record found!", vbInformation Else Call showDT End If End Sub

Chapter 4: Creating and Using Form Page 111 of 140 Management Information System SETEC University

Lab 3: Add record :

btnAdd

- code btnAdd (event: On_Click) Add records: Private Sub btnAdd_Click() Dim intSubjectID As Integer Dim strSubjectName As String Dim strDescription As String intSubjectID = InputBox("Input Subject ID:") strSubjectName = InputBox("Input Subject Name:") strDescription = InputBox("Input Description:") With rs .AddNew !SubjectID = intSubjectID !SubjectName = strSubjectName !Description = strDescription .Update .Close End With End Sub

Lap 4: record :

btnDelete

- code btnDelete (event: On_Click) Delete records: Private Sub btnDelete_Click() If MsgBox("Are you sure you want to delete this record?", vbYesNo, "Delete record") = vbYes Then rs.Delete Call btnPrevious_Click Else Exit Sub End If End Sub Page 112 of 140 Chapter 4: Creating and Using Form SETEC University Management Information System

Lab 5: Update record:

btnUpdate

- code btnAdd (event: On_Click) Add records: Private Sub btnUpdate_Click() With rs .Edit !SubjectID = txtSubjectID !SubjectName = txtSubjectName !Description = txtDescription .Update End With End Sub

*****End of Chapter 4*****

Chapter 4: Creating and Using Form Page 113 of 140 Management Information System SETEC University

Chapter 5 Creating and Using Report

Report?

Report Object MS-Access ដេញពី table

query ។

5.1. R port Report tool:

1. Navigation Pane, Table Query

Report

2. Ribbon, tab: Create  Reports,

icon: Report

Report Layout View :

3. Save Save report

5.2. View Report

1. Navigation Pane, Double-click Report Report

view Report View

Page 114 of 140 Chapter 5: Creating and Using Report SETEC University Management Information System

2. Ribbon, tab: Home  Views, icon: View

: icons Status bar

- Report View: Report Print

Report Clipboard

Chapter 5: Creating and Using Report Page 115 of 140 Management Information System SETEC University

- Print Preview: Report Print

- Layout View: Report (design)

- Design View: Report (formatting)

Layout View ។

Page 116 of 140 Chapter 5: Creating and Using Report SETEC University Management Information System

5.3. R port Report Wizard

1. Ribbon, tab: Create  Report,

icon: Report Wizard ។

Wizard :

2. “T l s u ri s” , t l query

3. List “Av il l Fi l s”, fields Report ។

Report fields table query

“T l s u ri s” table/query

fields ។

4. Next

Chapter 5: Creating and Using Report Page 117 of 140 Management Information System SETEC University

5. field grouping levels  Next

6. fields (Sort) Detail records 

Next

Page 118 of 140 Chapter 5: Creating and Using Report SETEC University Management Information System

7. Layout Orientation Report

- Stepped:

- Block:

Chapter 5: Creating and Using Report Page 119 of 140 Management Information System SETEC University

- Outline:

8. Next

9. Style  Next

Page 120 of 140 Chapter 5: Creating and Using Report SETEC University Management Information System

10. Report  “ r vi w th r port”

11. Finish

5.4. Label Label Wizard

1. Navigation Pane, Double-click table query

Label

2. Ribbon, tab: Create  Reports,

icon: Label

3. Label Wizard

:

Chapter 5: Creating and Using Report Page 121 of 140 Management Information System SETEC University

4. Label  Next

5. Text Label  Next

6. fields mailing label  Next

Page 122 of 140 Chapter 5: Creating and Using Report SETEC University Management Information System

7. field (Sort)  Next

8. Report  “S th l ls s th y will look print ”

9. Finish

Chapter 5: Creating and Using Report Page 123 of 140 Management Information System SETEC University

5.5. R port Blank Report tool:

1. Ribbon, tab: Create  Report,

icon: Blank Report

2. Field List pane, (+) Table

fields table

3. Double-click field Report ។

fields key: Ctrl +

fields ។

4. tools Control tab: Format

Logo, ,

Report ។

Page 124 of 140 Chapter 5: Creating and Using Report SETEC University Management Information System

5.6. Report Sections:

Report :

. Report Header: Report ។

Logo, ។

. Page Header ។

Report ។

. Group Header Records ។

Records ។

. Detail Row Record Source ។

. Group Footer: Records ។

(Aggregate Functions) ។

. Page Footer ។

. Report Footer: Report ។

Report ។

Chapter 5: Creating and Using Report Page 125 of 140 Management Information System SETEC University

5.7. Grouped Report Report Wizard:

. Record Source:

1. Select Query tables: Customers Orders

fields:

2. Save query qryTotal Freight by Shipped Date

. Report Wizard:

1. Ribbon, tab: Create  Report, icon: Report Wizard

Wizard Report :

Page 126 of 140 Chapter 5: Creating and Using Report SETEC University Management Information System

2. Tables/Queries, table query Record

Source Report

3. list “Av il l Fi l s”, fields Report

 Next

4.  Next

Chapter 5: Creating and Using Report Page 127 of 140 Management Information System SETEC University

5. field group

- field

(Data Type) Date/Time i on Grouping Options …

Grouping intervals

- OK

6. Next

Page 128 of 140 Chapter 5: Creating and Using Report SETEC University Management Information System

7. fields (Sort)

Detail records

- i on Summ ry Options …

-

Aggregate function (Sum, Avg, Min Max)

- OK

8. Next

Chapter 5: Creating and Using Report Page 129 of 140 Management Information System SETEC University

9. Layout Orientation Report St pp , lo k, Outlin …

10. Next

11. Style  Next

Page 130 of 140 Chapter 5: Creating and Using Report SETEC University Management Information System

12. Report  “ r vi w th r port”

13. Finish

Lab: េូរបដ្កើត report មួយ ូេរូប޶្ដរោម ៖

Chapter 5: Creating and Using Report Page 131 of 140 Management Information System SETEC University

Solution:

5.8. Homeworks

1. បដ្កើត tblCustomers ដ ើមបី埒ទុកព័ត៌掶ន诒ំពី诒តិថជិ ន

2. បដ្កើត tblProducts ដ ើមបី埒ទុកព័ត៌掶ន诒ំពី埒លិត埒ល

3. បដ្កើត tblOrders ដ ើមបី埒ទុកព័ត៌掶ន诒ំពីោរបញ្ជាទិញទំនិញពី诒តិថជិ ន

Page 132 of 140 Chapter 5: Creating and Using Report SETEC University Management Information System

4. បដ្កើត tblOrderDetails ដ ើមបី埒ទុកព័ត៌掶នបន្នែម诒ំពីោរបញ្ជា ទិញទំនិញពី诒តិថជិ ន ដោយរមួ

បញ្ចូលទ្ំ ទំនិញន្ ល诒តិថជិ នទិញ ។

5. បដ្កើត relationships រ玶្ tables :

6. បដ្កើត frmOrderDetailProductSub ដេញពី tblOrderDetail និ្ tblProducts រួេគណ侶រក

Sub Total និ្ Total ូេ޶្ដរោម :

Chapter 5: Creating and Using Report Page 133 of 140 Management Information System SETEC University

7. បដ្កើត frmOrders ដេញពី tblOrders រួេទញ Subform: frmOrderDetailProductSub ន្ ល

厶នបដ្កើតរួេ޶្ដលើោក់េូល ូេ޶្ដរោម :

frmOrders

frmOrderDetailProducttSub

8. បដ្កើត frmCustomerOrder (Mainform) ដេញពី tblCustomers រពមទំ្គូស combobox

មួយសំ殶ប់ ន្សវ្រក㾶មរយៈ ដ្ម ោះ诒តិថជិ ន ។

cboSearch

a. សរដសរ code បដ្កើត event: After_Update ដលើ cboSearch ូេ޶្ដរោម : Private Sub cboSearch_AfterUpdate() Dim SQL As String SQL = "Select * from tblCustomers Where CustomerName='" _ & cboSearch & "'" Form_frmCustomerOrder.RecordSource = SQL End Sub

b. ទញ frmOrder ន្ ល厶នបដ្កើតដ ើ្޶្ដលើ ោក់ᾶ subform កនុ្ frmCustomerOrder

រួេគូស buttons ពីរ ូេរូប޶្ដរោម :

Page 134 of 140 Chapter 5: Creating and Using Report SETEC University Management Information System

frmCustomerOrder

frmOrders

btnPreviewReport btnPrintReport

c. សរដសរ code បដ្កើត event: On_Click ដលើ btnPreviewReport ូេ޶្ដរោម : Private Sub btnPreviewReport_Click() DoCmd.OpenReport "rptCustomerOrder", acViewReport, , _ "CustomerID=" & Me.CustomerID End Sub

d. សរដសរ code បដ្កើត event: On_Click ដលើ btnPrintReport ូេ޶្ដរោម ៖ Private Sub btnPrintReport_Click() DoCmd.OpenReport "rptCustomerOrder", acViewNormal, , _ "CustomerID=" & Me.CustomerID End Sub

សំஶល់ៈ

- acViewReport: សំ殶ប់ បង្ហាញ report កនុ្ Print Preview

- acViewNormal: សំ殶ប់ print report

- េូរ诒នុវតតេំនុេ c និ្ d ដរោយដពលបដ្កើត report រួេ ។

9. បដ្កើត rptOrderDetailProductSub ដេញពី tblOrderDetail និ្ tblProducts រួេគណ侶រក Sub

Total និ្ Total ូេ޶្ដរោម :

Chapter 5: Creating and Using Report Page 135 of 140 Management Information System SETEC University

10. បដ្កើត rptOrders ដេញពី tblOrders រួេទញ Subreport: rptOrderDetailProductSub ន្ ល

厶នបដ្កើតរួេ޶្ដលើោក់េូល ូេរូប޶្ដរោម :

rptOrders

rptOrderDetailProducttSub

11. បដ្កើត rptCustomerOrder (Mainreport) ដេញពី tblCustomers :

 ទញ rptOrder ន្ល厶នបដ្កើតដ ើ្޶្ដលើ ោក់ᾶ subreport កនុ្ rptCustomerOrder

ូេរូប޶្ដរោម :

Page 136 of 140 Chapter 5: Creating and Using Report SETEC University Management Information System

rptCustomerOrder

rptOrders

12. រដបៀបកំនត់ដលខដរៀ្ដោយបង្ហា ញដោយសវ័យរបវតតន៍㾶មរកមុ (Over Group) :

a. ដបើក rptOrderDetailProductSub កនុ្ Design View រួេគូស textbox មួយដលើផ្埒ទ Detail

ដោយោក់ដ្មោះtxtNo ូេ޶្ដរោម :

Chapter 5: Creating and Using Report Page 137 of 140 Management Information System SETEC University

b. កំនត់ property របស់ txtNo :

- Control Source: =1

- Running Sum: Over Group

***End of Chapter 5***

Page 138 of 140 Chapter 5: Creating and Using Report