Professional Documents
Culture Documents
\&]] PRF ^H
1 1
&V; ;M
`F&N \
a &&F JU
&VG]
M
A&]]
PRF
:
&
:
&
:
&
9c d
#$%:'
&
9c d
U
e
(( :
*+:
9 179 Z 173 /S R Mc&
Tel: 010-011-012-016 603 314
Website: www.enteritc.com | facebook.com/enteritc
,-.
] 1: Y(` SQL Statement .............................................................................................................................. 1
] 2: '
Macro ........................................................................................................................... 19
] 3: V VBA.................................................................................................................................................................. 37
] 4: V VBA ............................................................................................................................................................ 57
] 5: Y DAO ................................................................................................................................................................ 71
] 6: 7 ComboBox & ListBox DAO............................................................................................................... 85
] 7:
Keyword Execute & DAO ................................................................................................................ 97
] 8: Sa
Stock ................................................................................................................................. 103
] 9: ] search &3& Stock .......................................................................................................................... 111
02,
%5
1. :
SQL 7(
D
J
&@oR
D 'Fo
Query p &,
&, & UI
&'
command Query
&'
Wizard
I7(F
(3& Database Engines
F SQL Language @
Apply 3& Database YY Microsoft Access, Microsoft SQL Server, Oracle ^
Microsoft Access
D SQL 3& Query Object
2.
SQL Statement:
1. Create Tab >
2. Query Design >
www.enteritc.com
02,
%5
select StudentID,FullName,Gender,Class
from TableStudentList
where StudentID > 4
order by FullName ASC;
7. Run >
8. $ d
www.enteritc.com
02,
%5
Select <FieldName1,[FieldName2,]>
from <TableName>
Where <Condition>
Order By <FieldName> ASC|DESC;
Example:
;$
/*
Select Statement ':
>
StudentID, FullName, Gender, Class
> TableStudentList
>
StudentID ;N 4
> ]&
D/*'
SQL Statement:
select StudentID,FullName,Gender,Class
from TableStudentList
where StudentID > 4
order by FullName ASC;
Output:
www.enteritc.com
02,
%5
www.enteritc.com
02,
%5
Select TableStudentList.StudentID,FullName,
Gender, Points
From TableStudentList Inner join TableStudyList
On TableStudentList.StudentID =
TableStudyList.StudentID
Where TableStudentList.StudentID > 4
Order by FullName;
Output:
www.enteritc.com
02,
%5
Select TableStudentList.StudentID,FullName,
Gender, Points
From TableStudentList Left join TableStudyList
On TableStudentList.StudentID =
TableStudyList.StudentID
Where TableStudentList.StudentID > 4
Order by FullName;
www.enteritc.com
02,
%5
Output:
Select TableStudentList.StudentID,FullName,
Gender, Points
From TableStudentList Right join TableStudyList
On TableStudentList.StudentID =
TableStudyList.StudentID
Where TableStudentList.StudentID > 4
Order by FullName;
www.enteritc.com
02,
%5
www.enteritc.com
02,
%5
SQL Statement:
Output:
( 2:
SQL Statement:
www.enteritc.com
02,
%5
SQL Statement:
Output:
10
www.enteritc.com
02,
%5
www.enteritc.com
11
02,
%5
Insert Into
TableStudentList(StudentID,FullName,Gender,Class)
Values(20,'Chea Phalla','Female','10E')
Output:
Update <TableName>
Set <FieldName> = <value>
Where condition
Example:
;$
/*
Insert Statement ':
>
Field StudentID p 20
> FullName p Chea Phalla
> Gender p 'Female'
> Class p '10E'
12
www.enteritc.com
02,
%5
SQL Statement:
UPDATE TableStudentList
SET StudentID = 15, FullName = 'Lim Kevtheara',
Class = '10B'
WHERE StudentID =20;
Output:
14.
( Table D* Table
:
Example:
;$
/*
&0 Record 6 @F StudentID,
FullName, Gender, Class TableStudentList @'3& Table 1]S
a TableStudentList2
SQL Statement:
Insert Into
TableStudentList2(StudentID,FullName,Gender,Class)
Select StudentID,FullName,Gender,Class
From TableStudentList Where StudentID > 5
Output:
( Table DC(E Table GA
:
15.
Example:
;$
/*
&0 Record 6 @F StudentID,
FullName, Gender, Class TableStudentList @'3& Table a] a TableStudentList3
DS'
SQL Statement
www.enteritc.com
13
02,
%5
16.
C( Table:
SQL Statement:
Output:
14
www.enteritc.com
02,
%5
SQL Statement:
SQL Statement:
www.enteritc.com
15
02,
%5
20.
Table:
Example:
;$
/* TableStudentList2 Database
SQL Statement:
Output:
16
www.enteritc.com
02,
%5
SQL Statement:
www.enteritc.com
17
02,
%5
18
www.enteritc.com
2:
!" Macro
1. :
Macro Object Microsoft Access Database
!" Button Menu &( ) + Form &,,-./
137, 9 Macro <= Autoexe ?
FormMainboardButton !@
,G Database
1. FormMainboardButton ! Create Tab >
2. Form Design >
www.enteritc.com
19
20
www.enteritc.com
www.enteritc.com
21
9. Run Button |
22
www.enteritc.com
www.enteritc.com
23
4. View >
5. Design View
.
/ Macro:
5.
137,9 Macro @, FormStudentList ?1
StudentID - Form <= FormDialog
1. Create Tab >
2. Macro >
www.enteritc.com
11. ,
Q OpenForm >
www.enteritc.com
25
26
www.enteritc.com
www.enteritc.com
27
28
www.enteritc.com
8. ,
!<=R QueryCustomerIDAndName >
9. Finish Button QU >
www.enteritc.com
29
30
www.enteritc.com
17. ,
!<=R FormCustomer >
18. Finish Button QU >
www.enteritc.com
31
32
www.enteritc.com
www.enteritc.com
33
34
www.enteritc.com
42. /-|7,
www.enteritc.com
35
36
www.enteritc.com
3: VBA
www.enteritc.com
37
38
www.enteritc.com
www.enteritc.com
39
14. ~4_!
> Year(date)
:
> Day(date)
: 1 31
:
> Hour(date)
: ;
> Second(date) :
> IsNumeric(varexpr)
: U
www.enteritc.com
> Len(string)
: Xw; String
: X
Space ~~4
6. Function !
Public Procedure:
27~4\g4. Function Capfirst U; 4
Convert w1w
1. Create Tab >
2. Module >
www.enteritc.com
41
42
www.enteritc.com
7. #$#% Comment:
4 Program ^ Dw Code Statement )
|
\ @U!4 Comment !@@
( ' ) Apostrophe ~ Statement Comment
Ex:
8. #$#% Statement:
4 VBA Access Statement wL
4L (Enter Key) Statement !;L; Error
Ex:
www.enteritc.com
43
44
www.enteritc.com
9. '!
*+ Elements:
Reserved Keyword
VBA Code !KL
? )
| 14 4\
// Reserved Keyword ; If, Loop, Len, Mid, Close, Or, Mod,
Syntax:
Dim VariableName [As Type]
Ex:
Dim
Dim
Dim
Dim
Dim
Dim
Result As Integer
Discount As Double
Birthdate As Variant
Name As String
Temp
Temp As Variant
www.enteritc.com
45
46
www.enteritc.com
Data Type
Size
Range
Byte
1 byte
0 to 255
Boolean
2 byte
True or False
Integer
2 byte
-32,768 to 32,767
Long
4 byte
-2,147,483,648 to 2,147,483,647
4 byte
-3.2823E38 to -1.401298E-308 to
(long integer)
Single
( double-precision
floating-point)
4.94065645841247E-324 to 1.79769313486232E308
For positive values,
Currency
8 byte
( scaled integer)
Decimal
14 byte
+/-79, 228, 162, 514, 264, 337, 593, 543, 950, 335
With no decimal point.
+/-7.9228162514264337593543950335 with 28
places to the right of the decimal, smallest non-zero number is.
+/-0.000000000000000001
Date
8 byte
Object
4 byte
String
10 bytes +
0 to approximately 2 billion
(variable-length)
String length
String
Length of string
10 to approximately 65,400
16 byte
Variant
22 byte +
(with characters)
String length
User-defined
Number
(using Type)
Required by
type.
(fixed-length)
Variant
(with numbers)
elements
www.enteritc.com
47
48
www.enteritc.com
www.enteritc.com
49
50
www.enteritc.com
www.enteritc.com
51
26. ~4_!
52
www.enteritc.com
> Module (Private) Vairable: Variable ! Dim Private declare Declaration
Section @U-!! Procedures Module ! N- !
Module w]!
Ex: Variable msg ! Declare Declaration @-U1! ButtonSum
! -! ButtonClear !
www.enteritc.com
53
> Global (Public): Variable ! Public declare General Declaration Section
( Module ) @U-!! Procedures Module !
Ex: Variable msg ! declare ModuleGlobal U-!?7
54
www.enteritc.com
www.enteritc.com
55
56
www.enteritc.com
4: VBA
www.enteritc.com
57
If <Condition> Then
<Statement>
End If
58
www.enteritc.com
Example:
If <Condition-1> Then
<Statement-1>
ElseIf <Condition-2> Then
<Statement-2>
ElseIf <Condition-n> Then
<Statement-n>
Else
<Statement-Else>
End If
Access 2010 Advance
www.enteritc.com
59
60
www.enteritc.com
www.enteritc.com
61
`
Example 2:
62
www.enteritc.com
Do
<Statements>
Loop while <Condition>
Example:
www.enteritc.com
63
Do
<Statements>
Loop while Until <Condition>
Example:
64
www.enteritc.com
Syntax:
Do While <Condition>
<Statements>
Loop
While <Condition>
<Statements>
Wend
Example:
www.enteritc.com
65
66
www.enteritc.com
Example:
www.enteritc.com
67
68
www.enteritc.com
9. CheckBox:
www.enteritc.com
69
11. ":
70
www.enteritc.com
5: DAO
www.enteritc.com
71
Dim db As DAO.Database
72
www.enteritc.com
Ex:
Set db = Currentdb
Set db = DAO.Opendatabase("C:\Enter.accdb")
3. TableDef Object:
TableDef Object 2 DAO &'k* Table f# Database
www.enteritc.com
73
74
www.enteritc.com
www.enteritc.com
75
Dim rs As DAO.Recordset
Set rs = db.OpenRecordset("TableProduct")
6. Add Record Do While # & Recordset:
76
www.enteritc.com
www.enteritc.com
77
78
www.enteritc.com
www.enteritc.com
79
80
www.enteritc.com
www.enteritc.com
81
82
www.enteritc.com
www.enteritc.com
83
84
www.enteritc.com
Listbox DAO
1. !"!# ComboBox & ListBox:
ComboBox ListBox Control Application
!" Microsoft Access '(*
,
./01
34 5 07, TextBox 8 '.: >
@ E ComboBox FG Item JK ListBox FG Items N.
P3 Add Items Q ComboBox ListBox S U S Wizard N
Table, Add Items 07,S Form N00 SQL Statement
2. & RowSourceType Property:
RowSourceType Property: Property *
FG ComboBox (
Bound
8 RowSourceType Property . 3 :
> Table/Query: .h ComboBox ( Bound Table Query J Database
> FildList: *
ComboBox 3 Bound N FieldName Table/Query JK
0FG
> Value List: * ComboBox 3JK 0' N
(Unbound) Table/Query 8
3. & RowSource Property:
8, RowSourceType Property
N0 ComboBox ListBox
* 8 RowSource Property E (4
SNFG RowSourceTyp RowSource Property
ListBox:
1. FormProduct Switch Q Design View >
2. ListBox ! Form 00"h ListBoxTableProduct Label '1 >
www.enteritc.com
85
8. 8, >
86
www.enteritc.com
www.enteritc.com
87
Ex:
88
www.enteritc.com
www.enteritc.com
89
90
www.enteritc.com
: Name = TextProvinceName
> Button
: Caption = ProvinceName
> ComboBox
: Name = ComboBoxProvinceNameInKhan
: Caption = KhanName
> TextBox
: Name = TextKhanName
> Button
www.enteritc.com
91
92
: Caption = ProvinceName
> ComboBox
: Name = ComboBoxProvinceNameInKhan
: Caption = KhanName
> TextBox
: Name = TextKhanName
> Button
www.enteritc.com
: Caption = ProvinceName
> ComboBox
: Name = ComboBoxProvinceNameAllInfo
: Caption = KhanName
> ListBox1
: Name = ListBoxKhanNameAllInfo
www.enteritc.com
93
: Caption = SangkatName
> ListBox2
: Name = ListBoxSangkatNameAllInfo
94
www.enteritc.com
6.
www.enteritc.com
95
96
www.enteritc.com
7:
Vardatabase.Execute sqlstatements
2. ButtonAdd 5:
www.enteritc.com
97
J7N5:
1. 3 TableStudents ,5 >
98
www.enteritc.com
Me.ListBoxFromClass.ColumnCount = 2
Me.ListBoxFromClass.ColumnHeads = True
Me.ListBoxFromClass.ColumnWidths = "1 in;1 in"
Me.ListBoxToClass.ColumnCount = 2
Me.ListBoxToClass.ColumnHeads = True
Me.ListBoxToClass.ColumnWidths = "1 in;1 in"
End Sub
www.enteritc.com
99
100
www.enteritc.com
www.enteritc.com
101
102
www.enteritc.com
8: Stock
www.enteritc.com
103
3. FormImport:
1. FormImport Property =2 >
www.enteritc.com
www.enteritc.com
105
4. FormExport:
1. FormExport Property =2 >
106
www.enteritc.com
www.enteritc.com
107
5. $:
1. FormStock =2:
108
www.enteritc.com
9: Search
www.enteritc.com
109
110
www.enteritc.com
www.enteritc.com
111