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

-

-
2007

681.3.06
32.973.26-018.2
95
. .
95
Microsoft Access 2007. .
.: -, 2007. 672 .: . + CD-ROM
( )
ISBN 978-5-9775-0187-3
- . Microsoft
Access 2007 () Microsoft SQL Server 2005 (). ,
Access- ,
.
.
"-". 50
.
- : "-".
,
681.3.06
32.973.26-018.2

02429 24.07.00. 18.09.08.


701001/16. . . . . 54,18.
. 5000 . 2802
"-", 194354, -, . , 5.
- 77.99.02.953..006421.11.04
11.11.2004 .
.

" ""
199034, -, 9 , 12

ISBN 978-5-9775-0187-3

. ., 2007
, "-", 2007


..................................................................................................................1
, ...........................1
.........................................................................................................1
..........................................................................2
..............................................................................................4
........................................................................................4
.........................................................................................................................5
........................................................................................7
.........................................................................................................8
.......................................................................................11
................................................................................13
...................................................................................................................13
I.
MS OFFICE ACCESS 2007....................................................................................15
1. ..........................................................................17
1.1. ............................................................................................17
1.2. ......................................................................................20
1.2.1. .........................................................................23
1.2.2. .........................................................................30
1.2.3. .........................................................................31
1.2.4. ............................................................................32
1.2.5. ? .......................................................33
1.3. ...........................................................................33
1.4. ................................................................................................39
1.5. .......................................................46
1.5.1. .......................................47
1.5.2. .....................................................47
1.5.3. .................................................49
1.6. ...........................................................51
1.6.1. .....................................................51
1.6.2. .................................................53
1.7. .................................................................55

IV

1.7.1. "--" ...........................................................55


1.7.2. "--"..............................................................60
1.8. , ..........................60
1.9. "--" ..........................................................63
2. ........................67
2.1. ...................................68
2.2. .....................................................70
2.3. ........................................74
2.3.1. ............................................................................76
2.3.2. ......................................................78
2.3.3.
........................................................................................................79
2.3.4. ..........................................83
2.3.5. ................................................................85
2.3.6. .........................................................................87
2.3.7. ........................................................................91
2.3.8. ....................................................................93
2.3.9. ..........................................94
2.3.10. ........................................................97
2.4. .............................101
2.4.1. ..............................................................101
2.4.2. ....................................................................102
2.5. ...................102
2.6. ..............................................................................104
2.6.1. ......................................................................................104
2.6.2. .........................................................................107
2.6.3. ...............................................................108
2.6.4. ......................112
2.7. .........................................................................................116
2.7.1. , .............................................117
2.7.2. MS Access 2007 ..........................................................................118
2.7.3. ..............................................................................119
2.8. ............................................................................121
3. .................................................124
3.1. ..............................................................................124
3.2. ........................................................................126
3.3. ...................................................129
3.3.1. ......................................................................129
3.3.2. ................................................................131

3.3.3. , ........................135
3.4. .........................................138
3.5. Microsoft Access .....................................................139
3.6. ......................................................141
3.6.1. Microsoft Access ....................146
3.6.2. Microsoft Access ................................................147
4. MS Access 2007 .................................151
4.1. .......................................................................................151
4.2. MS Access 2007 ...........................152
4.3. ...........................................................153
4.4. accde- ..............................................154
4.5. Microsoft Excel...................................................................156
4.6. Microsoft Access.............................................158
4.7. .................................................................159
4.8. MS Access 2007 ......................162
II. ..........165
5. Visual Basic for Applications ............................167
5.1. Visual Basic for Applications ................................................................167
5.2. ...................................169
5.3. , .......................................................170
5.4. MsgBox() ............................175
5.5. .............................................................178
5.6. ...........................................................................................................179
5.7. Visual Basic for Applications .....................................................181
5.7.1. ...........................................................................181
5.7.2. With...........................................................................................182
5.7.3. ...................................................182
5.7.4. ......................................................................................184
5.7.5. ...........................................................187
5.8. ....................................................................................188
6. SQL Access ....................................................................193
6.1. SQL ...................................................................................193
6.2. . SELECT ......................................................194
6.2.1. FROM ................................................................................195
6.2.2. WHERE..............................................................................196
6.2.3. ORDER BY.........................................................................197

VI

6.2.4. DISTINCT .................................................................................197


6.2.5. TOP...........................................................................................198
6.2.6. GROUP BY ........................................................................198
6.2.7. HAVING.............................................................................199
6.2.8. .................................................200
6.2.9. .............................................................................203
6.3. ...........................................................................205
6.3.1. INSERT .....................................................................................206
6.3.2. UPDATE ...................................................................................207
6.3.3. DELETE....................................................................................211
6.4. SQL ........................................................211
6.4.1. . CREATE TABLE ........................................212
6.4.2. . ALTER TABLE...................................215
6.4.3. . DROP.....................................217
6.4.4. . CREATE INDEX ......................................218
7. ...................................................220
7.1. ..................................................................220
7.2. ....................................................224
7.3. VBA....................................................................................230
7.4. ...............................................233
7.4.1. .......................234
7.4.2. <Shift>.................................................235
7.4.3. ..................................................236
7.4.4. ............................................237
7.4.5. ................238
7.5. ............................................239
8. .............240
8.1. .........................................240
8.2. ....................................................241
8.3. ......................................................241
8.4. ...............................................................................256
8.5. ..........................................268
9. ................................................287
9.1. .......................................287
9.2. MS Office Access ...........................................................290
9.3. .......................................................292
9.4. ..........................................297

VII

9.4.1. ..............................................300
9.4.2. VBA. Microsoft ADO ............................................308
9.4.3. ....................................................313
9.4.4. ....................................................315
10. ..................................................................326
10.1. Microsoft Excel 2007 ....................................................326
10.1.1. .......................................................................................327
10.1.2. Microsoft Excel 12.0 Object Library..........329
10.1.3. MS Excel
MS Access............................................................................................................330
10.1.4. Application................................................................331
10.1.5. , Real Estate.......................................332
10.2. Microsoft Word 2007 ....................................................345
11. ..........................................358
11.1. HTML- .............................................................................358
11.2. ..........................................................................................360
11.3. HTML- ..........................................................360
11.4. ...............................................362
11.5. ......................................................................364
11.6. .............................................................................365
11.7. .........................................................................................365
11.8. .........................................................................366
III.
"-" ..............................................................................................369
12. MS Access 2007
MS SQL Server 2005 .....................................................................................371
12.1. SQL Server 2005 ...............................................................372
12.2. MS SQL Server 2005 Developer Edition.....................................374
12.2.1. ..................................................................375
12.2.2. ......................................................376
12.2.3. MS SQL Server 2005 ..............................................377
12.2.4. SQL Server.....................................378
12.2.5. .............................................379
12.2.6. ............................................381
12.3. ......................................................................383

VIII

12.3.1. ...........................................................................385
12.3.2. ........................................................................................385
12.3.3. ..........................................................................................386
12.3.4. ......................................................................................386
12.3.5. ............................................................394
12.3.6. "-" ..................................396
12.3.7. Access- SQL Server ......................397
12.3.8. SQL Server .....................404
12.3.9. SQL Server.........................404
12.4. ODBC, OLE DB, DAO, ADO, ADO.NET .NET...........................405
13. " " MS SQL Server 2005 ...........................................409
13.1. MS SQL Server Management Studio .................................................409
13.2. .........................................................411
13.3. MS SQL Server 2005 .........................................................................412
13.4. .......................................................................................414
13.4.1. ..................................................414
13.4.2. .........................................................416
13.4.3. , ............................417
13.4.4. .................................................418
13.5. MS SQL Server 2005..............................................................419
13.6. ....................................................................421
13.7. Transact-SQL....................................................................................425
13.7.1. ....................................................................................425
13.7.2. ..........................................................................................426
13.7.3. ............................................................................................427
13.7.4. ..............................................................................................428
13.7.5. ..................................................................433
13.8. MS SQL Server 2005 .....................................................................438
13.9. ..........................................................................................442
13.9.1. ...................................................................................442
13.9.2. ................................................................................444
13.9.3. ..................................................445
13.10. .........................................446
13.11. ...................................................448
13.11.1. "--" .....................................................448
13.11.2. "--"........................................................452
13.12. .............................................................................................454
................................................................................................................455
13.13. .................................................................................458
13.14. ......................................................................................................461

IX

14. Microsoft Access................................466


14.1. ..................................466
14.2. .......................................467
14.2.1. ...................................................................................................467
14.2.2. .................................................468
14.2.3. ...................................................................................473
14.2.4. .........................................................................474
14.2.5. ...................................................................................................475
14.3. MS Access..............................................................481
14.4. ............................483
14.5. .....................................493
14.5.1. ...............................495
14.5.2. ...................................495
14.5.3. ................................................................500
14.6. ......................................................................................517
14.6.1. ......................................................517
14.6.2. .......................................................521
14.7. ......................................................................................523
14.8. .........................................................526
14.9. MS SQL Server 2005 Express Edition ...........................................................531
14.10. MS SQL Server 2005 MS Access 2007 ....................534
14.10.1. ..................................................................534
14.10.2. , , .......................535
14.10.3. ..........................................537
14.10.4. MS Access 2007..........538
14.10.5. ...........................................540
14.11. ........................................................................................541
.......................................................................................................543
1. .............545
2. - ...........................................................646

...........................................................................................650


,

, ? , ?
, . , . .
.


, ! , .
, . Real Estate, , "".
.
: " ".
. :
;
;

;
;
;

. .
. .

,
. ,
. ,
, . .
? ,
.
,
: Visual FoxPro 9, Delphi 6, SQL Server 2000, Visual Studio .NET
2003, Microsoft Access 2003, . ,
2007 ? ,
: "
(SP2), !" ,
SP2 ,
.
, , , .
. " " , .
,

. ,
, , . , - , ,
? MS Access !


! . . . :
" , , ,
, ". . -
, -

,
. Microsoft Access.
MS Access 97/2000. -

: , , , . . , , ,
.
MS Access 2002/2003. ,

. VBA . .
.
MS Access 2007 MS Office -

MS SQL Server 2005 Express Edition.


.
MS SQL Server 2005 Express Edition , "" MS Access 2007.
( 4 ).
, ,
, .
4 . ,
, . "" .
MS Access SQL Server,
- !

? ! Real Estate, ,
, , ,
: , (, ), " ".
:
, ;
: , ;
: ,

. .

, ? . .
, . , ,
"" , ,
! , , , . .
. , .
- .
, . . !
, !
- !


, , 1.
. 50 . , , .
. !


- .
, , "", . , ,
Real Estate, , ,
,
!


Microsoft Office Access 2007
Microsoft, .

.
, , , .
.
. ,
,
, .

Microsoft Access 2007. .
,
( ).
,
.
Stage, , ,
, , , Microsoft Office 2007, - ,
,
.

"-". ,
Microsoft SQL Server , .
, Microsoft SQL

Server, ,
,
.
" Windows SQL Server Microsoft
, Web-
, ,
Microsoft. ,

".
, "-",
80- - . 90- , . .

Microsoft SQL Server Microsoft Access Microsoft SQL Server Access.
. "-" , ,
, ,
, , ,
. , .
, ,
.
I , Microsoft Access 2007
.

2007. - 2007.accdb. -
-

, MS Office Access .

, ,
, , . , , ,
, ,
. .
,
,
. , , , . , ,
,
, , , .
: " , ". ,
. , , ,
.
, . - .
, , , , .


.
. -

, ,
. , , .
I , , -
. II,
, ,
,
. III MS Access, Visual Studio .NET
Delphi, "" .
, , .


.
I. MS Office Access 2007.

1 " " Microsoft Access . ,


, ,
. ,
.
.

2 " "
, ,
Microsoft Access
.
, .

,
.

3 " "
.
. MS Access
, , ,
.

4 " MS Access 2007"


, Microsoft Access .

II. .

5 " Visual Basic for Applications" . Visual


Basic for Applications (VBA)
. , , MS Visual C++, MS
Visual C#, MS VB, MS Visual FoxPro, Borland Delphi,
. VBA Microsoft Office, AutoCAD, CorelDRAW . VBA,
Microsoft Access. .
, , .
, . VBA.

6 " SQL Access"


. , , , .
,
. ,
.

7 " "
-

10

.
.
, .
:
, . ,
, .

8 " "
. , .

9 " "
,
.
, ,
.

10 " "
Microsoft Office 2007. MS Excel
MS Word MS Access,

.
.

11 " " -
HTML Help Workshop. , ,
<F1>.

III. "-".

12 " MS Access 2007 MS


SQL Server 2005"
, SQL Server 2005

11

accdb-
MS SQL Server.

13 " MS SQL Server 2005" MS SQL Server


SQL Server Management Studio.
Transact-SQL.

14 " Microsoft Access"


, ,
MS Access. , , , Access
2007.
.

1 " "
50

.

2 " -"
Real Estate dat- SQL Server
2005 .


MS Access ,
, , , ""
. ,
! , .
, , .
. , , -

12

, (,
, , . .) 6 000 000
.
20
10 .
, Visual FoxPro 6 Visual Basic 6 SQL Server 2000
, .
, , MS
Access. .
"-".
Real Estate
. , .
. "
", . ,
,
, ,
.
, ,
""
(. I), : "
", " " "
".
: " Visual Basic for
Applications", " SQL Access", "
" " MS SQL Server 2005".
MS SQL Server 2005,
"" MS Visual Studio .NET 2005.
,
.

13


, . , .

, .

,
,
.

- . , , , .


,
. : , ,
. 20 ,

, , ,
, .
"
Microsoft Access 2000", " " " Microsoft
Visual FoxPro 9".
,
MS Access 2007 SQL Server 2005.

I

MS OFFICE ACCESS 2007

,
, ,


-
. !

1.1.

, . , . ,
. ,
, .
. . !
, , , . , ,
, ,
, (. 1.1).
. ,
, - ,
- . , Microsoft Access

I. MS Office Access 2007

18

2007
, SQL Server
2005, . .
200500 .,
MS Office Access 2007.
1.1. ""

Address

50

District

15

Land

10

Year

Material

15

Comment

Memo

Wear

Cost

15

Line

10

Square

10

11

Picture

OLE

12

Kind

13

Elevator

14

Flat

15

Storey

16

Rooms

17

SquareFlat

18

Dwell

1.

19

1.1 ()

19

Branch

20

Balcony

21

Height

22

Account

23

FioHost

60

...

24

Pasport

Memo

25

Fio

60

...

26

Born

27

Status

20

, , . ,
.
, ,
. :
;
-

, .

. , - .
.
( ) ,
, . .

20

I. MS Office Access 2007

,
. , , ,
, ( 10 Windows
NT) .

, . . .
"-", III, . ,
.
. , . : ,
. Microsoft Office Access 2007 Microsoft SQL Server 2005
.
,
. . ,
.

, ,
. .

1.2.
.
70- (E. F. Codd) . -

1.

21

, . : , , , ,
, . . ,
. - .
, .
,
,
. , ,
, ,
. , .
. . , ,
,
. . .
, ,
. , . , ,
,
.
, .
. ,
"",
, , , , ,
.
. . .

22

I. MS Office Access 2007

,
. . :
, , . , - .
,
. ,
. ? ,
!
.
, .

, , . ,
, ,
. ,
. ,
, , -
.
. -

.
Microsoft Access . .
.

. .
,
. , . ,
? , ?
, ?
.

,
. .
,
. .

""

1.

23

Real Estate. . 1.1 ,


, .
.

. 1.1. Real Estate

. II
"tbl". ,
, "qwr".

1.2.1.
,
, .
""
. , ,

I. MS Office Access 2007

24

. , ,
, ,
. , .
. .
. , , . . FIOHOST, , , : FAMILY, NAME, SECOND.
. ADDRESS : , .
. 1.2 1.3.
1.2. ( street)

STREET

NAME

30

SIGN

10

FIRST

1.3.
STREET

NAME

SIGN

FIRST

173

174

175

176

564

1.

25

FIRST ,
: ,
.
FIRST ,
: , ,
: .

,
. , , 175 street, , , . street.
, , FIRST c .
.
( -) 175, .
(. 1.41.6).
1.4. ( building)

STREET

HOUSE

10

DISTRICT

15

LAND

10

YEAR

MATERIAL

15

COMMENT

Memo

WEAR

COST

15

10

LINE

11

SQUARE

10

I. MS Office Access 2007

26

1.4 ()

12

PICTURE

OLE

13

KIND

14

ELEVATOR

1.5.
( flat)

STREET

HOUSE

10

FLAT

STOREY

ROOMS

SQUAREFLAT

DWELL

BRANCH

BALCONY

10

HEIGHT

11

ACCOUNT

12

FAMILY

20

13

NAME

20

14

SECOND

20

15

PASPORT

Memo

1.

27

1.6.
( owners)

STREET

HOUSE

10

FLAT

NUMBER

FAMILY

20

NAME

20

SECOND

20

BORN

STATUS

20

.
, (. 1.2, 1.41.6):
, , . (. 1.2). .
.
. .
, , . ,
, . MATERIAL
DISTRICT building. ,
. : ,
, , . .
(wall district),
building . (. 1.3). :
district wall (. 1.7 1.8).

28

I. MS Office Access 2007

. 1.2.

. 1.3.

1.

29

1.7. ( district)

DISTRICT

AREA

15

1.8. ( wall)

MATERIAL

WALL

15

building .
wall
district (. 1.9).
1.9. building

STREET

HOUSE

10

DISTRICT

LAND

10

YEAR

MATERIAL

COMMENT

Memo

WEAR

COST

15

10

LINE

I. MS Office Access 2007

30

1.9 ()

11

SQUARE

10

12

PICTURE

OLE

13

KIND

14

ELEVATOR

1.2.2.
,

.
. , Microsoft Access,
, .
, .
. ,
Microsoft Access
Null . Microsoft Access : , .
,
. : (), , ,
, ,
. STREET ( ) street
.
DISTRICT ( ) MATERIAL ( ) district
wall. .
building, ,
. -

1.

31

.
, .
flat () . :
.
. , . Access .
( ).
, Microsoft Access 2007 . .

1.2.3.
,
.
flat () (. 1.3). ACCOUNT ( ),
(: FAMILY, NAME, SECOND
PASPORT) . account
ACCOUNT
(. 1.10).
1.10.
( account)

ACCOUNT

FAMILY

20

NAME

20

SECOND

20

PASPORT

Memo

32

I. MS Office Access 2007

1.2.4.
,
. Microsoft Access : --,
--, -- --.
"--" , -

.
flat account (. 1.4). .
ACCOUNT. ! , ,
(ACCOUNT) ( 5- ).
.
, ,
, .
"--".

street building.
street building.

STREET. street.
building
flat, flat owners. ,
. .
"--"

"--". . ,
, "--".
.
"--"

,
,
.
, . . . Microsoft Access
.
- ,
"--".

1.

33

"-" .
. 1.9, .

. 1.4.

1.2.5. ?

, .
Oracle DB2, ,
.

1.3.
Microsoft Access 2007 . .

34

I. MS Office Access 2007

, .
Microsoft Office. Microsoft Office Access 2007.
. .
Microsoft Office
Access (. 1.5).

. 1.5. Microsoft Office Access 2007


. Microsoft Access 2007 ,
.
.
. , . Real Estate.
. 1 (. 1.6).
. Microsoft Access , ( ) ,
: , -

1.

35

, , , . , -
. Real Estate.accdb,
.

. 1.6. Real Estate

MS Office Access 2007 :


accdb Office Access 2007.

mdb;
accde MS Office Access 2007,

. accde- . accde- VBA,


. accde mde;
accdt MS Access 2007;
accdr ,

.
accdb accdr ""
MS Office Access 2007. , accdb.
,
Microsoft Office.
, Microsoft 20032006 .
MS Office. Microsoft Office Access 2007 -

I. MS Office Access 2007

36

. , Microsoft
Access . , - . Microsoft Office Access (. . 1.5)

. . ,
,
. Office (. 1.7).
.

. 1.7. Office Microsoft Access 2007

MS Access 2007 . , , .
, (. 1.8).

. Microsoft
Office Access 2007 , , .

1.

37

, .
. (. 1.8) , . . Microsoft Access .
.
.

. 1.8. Microsoft Access 2007

, .
, . ""
, .

.
1024768 , MS

38

I. MS Office Access 2007

Office . , MS Office Access 2007 .


.
.
,
, . ,
, .
.
Microsoft Access 2007
, ,
. ,
:
,

. , .
. .


.
, .
Access , , . , , .
.
OK.
Microsoft Access 2007
.
.
, , , , .
,
MS Office Access 2007 . , ,

1.

39

, . Office Access 2007


, . , .
Office. Access. .
.
.

1.4.
Microsoft Office Access 2007:
;
;
SharePoint;
;
.


,
.
. .
.
. ,
STREET ( ),
. STREET
255 , MS Office Access 2007
.
.
, , . .
!

, SharePoint, URL.

40

I. MS Office Access 2007

, .

.

, .
.
1 (. 1.9). . ( ) ,
() .
! .
.

. 1.9.
Microsoft Office Access 2007

, . . 1.11
Microsoft Access 2007.
64 ,
.
. Microsoft Access ,

1.

41

Visual
Basic for Applications (VBA).
1.11. MS Access 2007

,
. 255 .


. 64 .
. Memo
. Office Access 2007
( ), Access Memo.

().
. ,

,
,

:
0 "" 1
( : 1) ""


15 4


OLE

, , ,
, , . .

I. MS Office Access 2007

42

1.11 ()

Web

Web-


.
,
.
, ,
Microsoft Office Word 2007

.

.
Office. Access. . . .
.

MS Office Access 2007 .


, .
, , , , .
. MS
Access
OLE (Object Linking and Embedding, ).
OLE . . OLE
, . , ,
, MS Access 2007. ,

1.

43

OLE , OLE-.
, Access JPEG, , ,
, OLE- JPEG. , MS Access 2007
- , .

, , .
, .
, , , , . ,
MS Office Word MS Word,
, Access.
Word , .

building.
. 1.8. , , . ,
. (. 1.10).
1. STREET

<Enter>. . .
2. .

. <Enter>.
. , !
3. .

.
4. . -

. .
5. .

. -

44

I. MS Office Access 2007

. 9999 , .
6. 15 .

. 1.10. building

. ,
(. 1.11). , 1 building
OK.
Access.
, ! building
(. 1.12).

1.

45

. building ,
Real Estate. , STREET, , .
STREET?

. 1.11.

1.12. ,
STREET

HOUSE

FLAT

STOREY

ROOMS SQUARE

DWELL

BRANCH

ACCOUNT

14

102

60,8

40

20

3450

14

102

100

70

28

1000

14

102

78

60

16

4321

14

102

90

80

666

14

102

100

95

30

778

14

102

10

200

190

9787

14

102

10

170

150

10

879

179

104

30

20

23210

179

104

42

30

11

3267

179

104

27

20

6666

179

104

100

90

4587

: flat, owners, account,


street, district wall.

46

I. MS Office Access 2007

1.5.

, , . .
.
, Microsoft Office Access 2007,
, . "".
, ,
. .

, .
, , . . , . ,
.
. , ,
. ,
Access 2007 .


. -, , - , . .
.
, .
,
.
,
, . 1.2.

1.

47

.
.


. , . - . .
flat (. . 1.4) ACCOUNT ( ).
.

1.5.1.

, () . ACCOUNT
flat. :
1. flat (. 1.12).

Access Real Estate flat .


2. . .

ACCOUNT,
.
3. .
4. ACCOUNT , -

( ).
5. .
6. , ,

. .

1.5.2.
account ( ).
,
, ACCOUNT.

48

I. MS Office Access 2007

:
1. account .

Access Real Estate account


. .
.

. 1.12. ACCOUNT

2. ACCOUNT,

. , ,
(. 1.13).
3.


Microsoft Office Access 2007.
ACCOUNT (. 1.14).

4. .

1.

49

5. , ,

. .

. 1.13.

. 1.14.

1.5.3.
flat ().
: STREET
( ) HOUSE ( ) FLAT ( ).
1. flat (. 1.15). -

Access Real Estate flat


. .
.

50

I. MS Office Access 2007

2. STREET,

. , ,
. <Ctrl> , , HOUSE FLAT. (. 1.15).

. 1.15.

. 1.16.

1.

51

3.


Microsoft Office Access 2007. . : , ,
. , ACCOUNT flat
. , .
. : flat. . 1.16.
!

4. -

1.6.
, ,
. . ,
, , , . . , ,
, , ,
.

.
,
Microsoft Access 2007.

1.6.1.

,
. , . 1 9, (. 1.17).

I. MS Office Access 2007

52

district (), :
1. district .

Access Real Estate district


. .
.
2. .
3. >=1 And <10 <Enter>.

.
4. : 1 9

. , . <m>.
5. -

. 1.17. DISTRICT ( )

1.

53

, 19,
(. 1.18).

. 1.18.

1.6.2.
. ,
: ,
. , :
1. flat . -

Access Real Estate flat


. .
.
2.


Microsoft Office Access 2007.
(. 1.19).
.

3. :

.
4. .

. .
5. .

flat. -

54

I. MS Office Access 2007

SQUAREFLAT. [SQUAREFLAT] (. 1.20).

. 1.19.

. 1.20. Microsoft Access 2007

1.

55

6.

DWELL, .
BRANCH BALCONY :
[SQUAREFLAT]=[DWELL]+[BRANCH]+[BALCONY]

7. , OK.
8.

(. . 1.19). ,
: . .
9. -

(. 1.21).

. 1.21.

1.7.
. . . .
. .
. (. 1.22).

1.7.1. "--"
district () building ().
"--".

I. MS Office Access 2007

56

. 1.22.

.
1.

Microsoft Access 2007. (.


. 1.22).
2. -

.
3. .
4. .

.
5. district () -

. .
6. district (. 1.23).

building ().
7. district building -

DISTRICT. DISTRICT
( ), , , "" DISTRICT building.

1.

57

.
(. 1.24).

. 1.23. building

8.


. Microsoft Access 2007
, , .

"" ""
, "" .

( ).

MS Access 2007
.
, ,
, .

I. MS Office Access 2007

58

. 1.24. "--"
district building

. , building , , district ,
.
, . .
.
, .


,
district, building
MS Access .

district,
Access 2007 . ,
? ,
!

,
. . 1.4.
flat owners. flat : STREET+HOUSE+FLAT.

1.

59

:
1. STREET flat

.
2. <Shift> , ,

HOUSE, FLAT. <Shift>.


: STREET+HOUSE+FLAT.
3. -

flat, , , ""
owners.
4. .

(. 1.25). ,
(. . 1.24), DISTRICTDISTRICT , ,
flat owners
.

. 1.25. "--" flat owners


60

I. MS Office Access 2007

5. , .
6. , . -

.
.
(. 1.25)
. . .
flat owners ,
. 1.25.

1.7.2. "--"
account flat, . .
. :
1. ACCOUNT (

).
2. , ,

ACCOUNT flat. . .
3.

( account). ( flat).
( ).

1.8. ,

, , ,
, MS Access . -

1.

61

! ,
. . .
flat () 16 291 .
, , . ,
. ! , , . . ,
. , :
1.

Microsoft Access 2007.


. (. 1.26).

2. OK.
3. . flat -

.
4. -

: STREET, HOUSE, FLAT,


(. 1.27).

. 1.26.

62

I. MS Office Access 2007

5. (. 1.28).

. 1.27.

. 1.28. flat

flat ,
. Real Estate, ,
" flat", . .
,
. ,
.
. ,
, (. 1.29).
. 1.29 , .
. 1,
48, 45,

1.

63

42,4 2,
30,4 2. , .
.

, , , .
.
<Delete>. (. 1.30).

. 1.29. flat

. 1.30.

1.9. "--"
"" (.
1 1). .

64

I. MS Office Access 2007

. ,
, .
" " .
"--" : (. 1.31).

. 1.31. "--"

, "--". , -
(. 1.32), , . -
, , -.
,
. :
.
( ) : " " "

1.

65

". . 1.33
"--" "--"
.

. 1.32. -

. 1.33.

I. MS Office Access 2007

66

"--" "-" "--" .


,
, ("--"). ,
("--"). , ("--").
" "
"".

" "
"- " " " (GoodsID + NumberPart).



Microsoft Access 2007
.
- . . , , , .
: . .
Microsoft Access 2007 , ,
. .
, . , . ,
, . . , , . Microsoft Office Access 2007
, ,
,
.

I. MS Office Access 2007

68

2.1.

MS Access, .
(. 2.1).
:
;

;
,

;
;
;
.

. 2.1. MS Access 2007


, , . MS Access 2007

2.

69

. .
. Access-
.
. MS Access .
. .
. ,
.
. ,
() , ,
. . MS Access. . 2.2 ,
user () Real Estate.

. 2.2.

I. MS Office Access 2007

70

MS Office Access 2007 ,


<Alt>, , . <Alt> .

. . . . ,
, ,
"" , ,
. ,
!

2.2.

Microsoft Access 2007 .
, . , , ,
.
.
. .
, .
Building ().
building -:
street () district ().
1.

,
(.

2.

71

. 2.1). .
.
2. . (. 2.3).

.
building.

. 2.3.

3.
building.

, .
.
. building
,
STREET DISTRICT. -,
. . street
district. NAME, SIGN AREA.
4. -

. ,

72

I. MS Office Access 2007

: . .
5.

: , , , ,
. ,
(. 2.4). .

. 2.4.

6. . Access 2007 25 .
7. -

. , ,
. .
. . 2.5 Building .
,

2.

73

. . .

. 2.5.

, MS Access 2007,
. MS Access :
;
;
;
;
.

. .
.
( , ,

74

I. MS Office Access 2007

). . . .
, .
. "" ,
. MS
Access 2007 Office (. . 1.7).
. , .

2.3.

,
.
(. 2.6), Microsoft Access 2007.

. 2.6. , .

2.

75


building.
. , ,
. . . 2.6 1.
. ( Real Estate) .
Building,
(. 2.7).

. 2.7. , .

MS Access
2007: , Building -

I. MS Office Access 2007

76

.
. .
.
.
, . <F4>. MS Access, , . .
. MS Access 2007
:
, ;
, ,

, ;
,

;
,

;
.

2.3.1.
, . , . ,
. .
.
,
. ,
.
.
:
1. , , ,

, .
2. .

2.

77

3. .

. . -

4. ,

. (. 2.8).
.

. 2.8.

MS Access 2007
. , . , .

, (
- )
/.

78

I. MS Office Access 2007

2.3.2.
,
. MS Office Access 2007 "" , ,
. , MS Office 2007,
, . ...\Microsoft
Office\Office12\Bitmaps\Styles .

. 2.9.

:
1. .


.
.

2. . MS

Office Access 2007 .


3. .

2.

79

4. .

: .
.
.
5. . (. 2.9).
6. OK.

, ,
. .

, .
. , .
.
.

, .
, , ,
.

, . .

2.3.3.

MS
Access 2007 ,
(. 2.10). . 2.1 .

I. MS Office Access 2007

80

. 2.10.

2.1.




. ,
, ,

. ,
. . MS Access
.
, , , VBA
. ,
. ,

. , .
,

2.

81

2.1 ()

/.

.

.


.
OLE ( ).


.
,
. , .
( ).
,
Bit MS Access
. ,

Bit MS Access
. .
. . MS Access 2007
. MS Access

. OLE.

I. MS Office Access 2007

82

2.1 ()

.
. OLE.

.
.
Web-,
.

. , , , . ,


, .

MS Access 2007 .
,

. , .

, . , , "". .
,
. OLE , . . ""
.
, .
.
.

,
, . , OLE

2.

83

.
.

. ,
.

2.3.4.
,
(. 2.11). . 2.2 .

. 2.11.

2.2.



2.2 ()

I. MS Office Access 2007

84

.
.

2.

85

2.2 ()

2.3.5.
, , c ,
,
.
1. MS Access 2007 .
2. .

. .
3. .

. .
4.

I. MS Office Access 2007

86

5. . , -

.
6. building.

.
7. . -

. ,
, .
. 2.12 Microsoft Access 2007 . !

. 2.12.

building ,
Building, . STREET.

2.

87

2.3.6.
, ,
, . MS Access
.

( ) MS Access
.
Building Real Estate.accdb. , . .
1. ,

" " . ""


.
.
.

2.

.
.

, . . (. 2.13).

. 2.13.

3.

" ".
(. 2.14).

I. MS Office Access 2007

88
street,


" "....

. 2.14.

4. . , -

, .
street .
5. MS Access

street, (. 2.15). .
6.

. , .
. .
. .

2.

89

. 2.15.

7.

(). ,
street . (. 2.16).
8. . .

building, street.
46 , ,
.
"" .
9. ,

. "" .

(. . 2.14)
, , , "" -

90

I. MS Office Access 2007

, ""
.

. 2.16.

,
. MS Access 2007
. -, "" ,
. -, .
, . , , . "" -
<Ctrl>.

2.

91

2.3.7.
.
, HOUSE building (. 2.17).
.
1. building,

Microsoft Access 2007


. . ,
building ( ), , building, Real Estate.
2. HOUSE. -

. c , , .
, . ,
. ,
.
3.

. 2.17. HOUSE

, . -
<Shift> .

92

I. MS Office Access 2007

, .
MS Access 2007
. , .
.
.
.
(. 2.18).
.
.
1. building,

Microsoft Access 2007


. . ,
building ( ), , building, Real Estate.

. 2.18.

2. COMMENT.

.
.
.
3. .

2.

93

4. .

.
5. "COMMENT"

. . .

, .

2.3.8.
,
"" "", . ELEVATOR (). .
. .
. .
.
.
. .
. ,
(. 2.19).

. 2.19.

94

I. MS Office Access 2007

2.3.9.

building () KIND . : , , . .
1 4. ,
, , "--"
building , . , Microsoft Access 2007
, , , .
.
1. ,

" " . ""


. .

2.

.

. : Microsoft Access !

3. . -


. , ,
,
. . .
4. (. 2.20) .

, . .
. (. 2.21).
5. (. 2.22).

, 1
, 2 , 3 , 4 .

2.

95

. 2.20.

. 2.21.

6. (. 2.23) building,

.
. KIND ( ).

96

I. MS Office Access 2007

. 2.22.

. 2.23.

7. (. 2.24)

. , , .
().

2.

97

. 2.24.

8. -

. ,
, .

2.3.10.
, . Microsoft Access , OLE
. OLE, ,
, , . .
(. . 2.6).
,
PICTURE ( OLE) building.
1.

98

I. MS Office Access 2007

2. . -


. , , ,
. .
3. ,

: " OLE" (. 2.25). - "" .


.
4. -

.
. .
5. . Microsoft Access

.
(. 2.26).
.

. 2.25.
Building

,
.
, . .

2.

99

"" .
,
. .
,
, .

. 2.26. :
; ;

.
(Flats), building, ,
:

I. MS Office Access 2007

100

1. Real Estate.
2. Building. ,

.
3. (. . 2.6).


( ).
. .
4. , -

.
5. . -

(. 2.27).
6. ,

OK.
, .
7. ,

,
. . - .

.

. 2.27.

2.

101

2.4.


, .

2.4.1.
,
( ) (. . 2.17). ,
. . , . .
, -

. . ,

, .
, .
-

.
. , ,
. , .

, .
. ,
, , .
, -

. . , ,
.

I. MS Office Access 2007

102

2.4.2.
, ,
, .
.
.

, , , .
, .
,

. <Shift>. .

, ,
.

(. . 2.11) : , , . .

2.5.

.

. .
, , " ".
<Enter> <Tab>, .
. .
.

2.

103

:
1. .

( ) .
.
.
2. MS Ac-

cess 2007 . .
3.

(. 2.28).

. 2.28.

I. MS Office Access 2007

104

4.

, . . .
5. .

, , ,
. . , .
( )
.

2.6.
Building .
,
, - .
, ,
. ,
, ,
, flat, owners account, .
Flats ().

2.6.1.
,
, . , , . Flats flat, Flats,
, , . .
1. MS Access 2007 .
2. .

, .

2.

105

3. .

flat , account. .
4. flat account -

, . 2.29 ( ""
).
,
. ACCOUNT ( ), , .
5. flat account

(. 2.30).
.
6. , . ,


. FLAT.
7. Flats.

. 2.29.

I. MS Office Access 2007

106

. 2.30.

STREET HOUSE:
[Forms]![Building]![STREET]
[Forms]![Building]![HOUSE]

. ,
, Building Street (), , Building
House ( ). . 2.30.
. .
SQL. . SQL, ( 2.1).
2.1. Flats SQL
SELECT flat.STREET, flat.HOUSE, flat.FLAT,
flat.STOREY, flat.ROOMS, flat.SQUAREFLAT,
flat.DWELL, flat.BRANCH, flat.BALCONY,
flat.HEIGHT, account.ACCOUNT, account.FAMILY,
account.NAME, account.SECOND
FROM account INNER JOIN flat ON account.ACCOUNT = flat.ACCOUNT
WHERE (((flat.STREET)=[Forms]![Building]![Street])
AND

((flat.HOUSE)=[Forms]![Building]![House]))

ORDER BY flat.FLAT;

,
,
SQL. MS Access , II.

2.

107

2.6.2.
,
, .
, Flats ,
, flat . , , . .
. ,
Flats , Visual Basic
(Visual Basic for Applications, VBA). 2.2. MS
Access, VBA . 5.

. 2.31. Flats ()

108

I. MS Office Access 2007

2.2. Flats
Private Sub Form_BeforeInsert(Cancel As Integer)
Me!STREET = [Forms]![Building]![STREET]
Me!HOUSE = [Forms]![Building]![HOUSE]
End Sub

MS Access . .
Me (. 2.31). , .
, , (Street+House)
.

2.6.3.
, . ( Flats) .
, "--". .
. ,
""
"". MS Access ,
, .
. . 2.32 : Building ( ) Flats ( ). Flats Owners ( ).
.
1. Flats .
2. ,

" " . ""


. .

2.

109

3.

. ,
.

.

4. , , -

,
. . .

. 2.32. Real Estate

5. ,

. ""
. .
owners (. 2.33).

110

I. MS Office Access 2007

6.

. Flats , : flat account.


owners. Flats owners, ,
,
. .
: STREET+HOUSE+FLAT (. 2.34).
7. .

Real Estate. ,
Owners. .

. 2.33.

Flats.
Owners. . ,
, .
(. 2.35).

2.

. 2.34.

. 2.35. ,

111

112

I. MS Office Access 2007

owners.
. STREET,
HOUSE FLAT . . . , .
.
,
: . STREET, HOUSE FLAT.
<Delete>.
. .
. , . , ,
. - <Ctrl>,
-
<Shift>. ,
. 2.32.

2.6.4.

Flats , .

. 2.36.

2.

113

, , . 2.32,
- (. 2.36).
. Flats
() Building (), . .
.
Building.
1. Building .
2. ,

" " . ""


.

3.

.
4. Building, -

. .
5. , , -

,
. . .
6. , . 2.37.

, , .
7. , -

.
Flats (. 2.38).
8. . -

Flats , ,
: .
9. . -

, , . Access
.

114

I. MS Office Access 2007

. 2.37.

. 2.38.

2.

115

10. . -

. ,
VBA , Microsoft Access .
, Wizard. () MS Access. , . Building
. . . "" 2.3.
2.3.
Private Sub 190_Click()
On Error GoTo Err_190_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "flats"
DoCmd.OpenForm stDocName, , , stLinkCriteria
Exit_190_Click:
Exit Sub
Err_190_Click:
MsgBox Err.Description
Resume Exit_190_Click
End Sub

,
, ( 2.4).
2.4.
Private Sub 190_Click()
DoCmd.OpenForm "flats"
End Sub

, Flats Microsoft Access 2007, Visual Basic for Applica-

116

I. MS Office Access 2007

tions 6.5. , VBA


.
, Flats Building . . .
. , ,
<Enter> , , , .
. Building
.
.
, , .
,
(. . 2.28). 190.
"" .
!
, .
, , - .
, , . .
. OK.

2.7.
, , , . Microsoft Access .
. ,
. !

2.

117

2.7.1. ,
, :
1. C .

.
2. Microsoft Access ,

. (. 2.39).
3.


.
,
, (
).

4. .
5. . .

. 2.39. ,

118

I. MS Office Access 2007

, , MS Access
,
.

2.7.2. MS Access 2007


, Microsoft Access, . .
: , , 1963 30%.
2500 2.
. .

. 2.40.

2.

119

: Building. Microsoft Access 2007 ,

. .
. .
Building: (. 2.40). , , .
Microsoft Access 2007.
, ,

, . ,
1909 ,
.
,

, .
"Is Not Null". -

. , , .
.


(. . 2.39). Building,
, ,
: " ".
, . , :
" ".


- - , .

2.7.3.
,
Microsoft Access ,
. . . 2.6

I. MS Office Access 2007

120

, .
, ? . , ,
, . . Microsoft Access ,

. (. . 2.39). . . . , (. 2.41).

. 2.41.

, .

2.

121

2.8.
Real Estate - (. 2.42).
Start. Building
. 2.5. 2.6 . MS Access 2007
.

. 2.42.
Real Estate

2.5. Building
Private Sub 2_Click()
'
On Error GoTo Err_2_Click
Dim stDocName As String
Dim stLinkCriteria As String
DoCmd.Close

'

I. MS Office Access 2007

122

stDocName = "Building"
DoCmd.OpenForm stDocName, , , stLinkCriteria
Exit_2_Click:
Exit Sub
Err_2_Click:
MsgBox Err.Description
Resume Exit_2_Click
End Sub

2.6. Stop
Private Sub 1_Click()
' STOP
'
' MS Access
DoCmd.Close

'

End Sub

. 2.43.
Real Estate

2.

123

Microsoft Access 2007 ,


Real Estate.accdb
. Microsoft Access
2007 Office (. . 1.7), Access. . 2.43.
, .
. building.ico.
Start.
. Microsoft Access 2007 .
.




.
.
. ,
. ,
.
"" , : , , , . Flats
() Document.

3.1.
MS Office Access 2007
. , . ,
, .
,
, .

3.

125

MS Access
, , .
.
.
. -.
1. street,

.
2. MS Access 2007

. MS Access
(. 3.1).
3. , , -

.
MS Access 2007
street.

. 3.1.

,
.
Microsoft Access 2007,
,

126

I. MS Office Access 2007

.
.
,
, ,
.
. .

3.2.
Flats street owners. , Flats ,
, Building.
, , Document.
1. MS Access 2007 .
2. .

, .
3. .

. Flats . street
owners, .
. , . 3.2.
4. street Flats MS Access -

. Flats
street, . Flats
owners .
5. STREET Flats. -

, ,
STREET owners. HOUSE FLAT (. 3.3).
6. ,
Document

street, owners Flats,

3.

127

. , MS Office Access 2007 . .


.

. 3.2.

. 3.3.

7. Document

. FLAT Flats. FLAT:


[Forms]![Flats]![FLAT]

I. MS Office Access 2007

128

8. , Document.


. 3.1.
9. Document. , -

Flats (), ,
, Building ().

FLAT: [Forms]![Flats]![FLAT]
.
. FLAT Flats.

. .
SQL. .
SQL, .
3.1.
SELECT street.NAME, street.SIGN, flats.HOUSE, flats.FLAT,
flats.STOREY, flats.ROOMS, flats.SQUAREFLAT, flats.DWELL,
flats.BRANCH, flats.BALCONY,
flats.HEIGHT, flats.ACCOUNT, flats.FAMILY, flats.NAME,
flats.SECOND, owners.NUMBER, owners.FAMILY, owners.NAME,
owners.SECOND, owners.BORN, owners.STATUS,street.FIRST
FROM street INNER JOIN (flats INNER JOIN owners ON
(flats.HOUSE = owners.HOUSE)
AND (flats.FLAT = owners.FLAT)
AND (flats.STREET = owners.STREET))
ON street.STREET = flats.STREET
WHERE (((flats.FLAT)=[Forms]![Flats]![Flat]))
ORDER BY owners.NUMBER;

,
,
SQL. MS Access , II.

3.

129

3.3.

MS Office Access 2007 . . , . .
. .

, :
. .
. . -

, ,
.
. .

. , , .
.

. ,
.
. . -


.
. .

.
. .

3.3.1.
MS Access 2007
. , , . -

130

I. MS Office Access 2007

: , . .

.

. 3.4.

. 3.5.

3.

131

, Microsoft Access , (. 3.4). .


.
. . , .
/ . . . . 3.5.

3.3.2.
MS Access 2007 .
,

. , . . , .
OLE , . .
""
. ,
. .
.

,
, .
, OLE
.
.

. ,
.
, . 3.6, :
1. . -

.
2. .

I. MS Office Access 2007

132

3. . -

Document.
4. -

/ .
5. .
6. -

Document.
.
7.

"". . .
8. .
9. . Arial

10 . .
.
10.

. .

11.

.

.

12. -

" , ".
13. NAME, SIGN, HOUSE FLAT

. . , <Shift>.
14. . -

- .
, . . 3.1.
15. NUMBER, FAMILY, NAME, SECOND, BORN STATUS

. , Access, .
. 3.6.

3.

133

. 3.6. Document

3.1.

I. MS Office Access 2007

134

3.1 ()

3.

135

3.1 ()

3.3.3. ,

, ,
, . , . . MS Access 2007 .
.
1. .
2.

.
.
(. 3.7).

3. , .

136

I. MS Office Access 2007

4. ,

.
5. OK. .

. 3.7.

,
(. 3.8).
: " ", . :
1. .
2.

. . . .

3. , , -

. .
4. .

.
5. .

3.

137

. 3.8.

6.

. -

(. . 3.8).
7. ,

.
MS Access Now(). OK. =
.
8. 49 : " ".
9. .

I. MS Office Access 2007

138

10. . Arial

10 . . .
11.

. .

12.

.
. .

3.4.

,
.
.
Flats .
VBA, , 3.2.
3.2.
Private Sub 40_Click()
On Error GoTo Err_40_Click
Dim stDocName As String
stDocName = "Document"
DoCmd.OpenReport stDocName, acPreview
Exit_40_Click:
Exit Sub
Err_40_Click:
MsgBox Err.Description
Resume Exit_40_Click
End Sub

3.

139

40. Document. acPreview.


Microsoft Access, VBA
MsgBox Err.Description.

3.5. Microsoft Access


Microsoft
Access , .
1,5 , 1 . . :
1. .
2. , -

. 3.9.

140

I. MS Office Access 2007

3. (. 3.9).

, . , .
4. ,

. , (. 3.10),
, Access 2007.
, .

. .

.

. 3.10.

3.

141

3.6.
, Microsoft Access, .
. , (, , . .), , !
,
(, , . .).
1,
. (. 3.11).

. 3.11.

(street.NAME, , HOUSE, ., FLAT).


<Delete>. SIGN
ADDRESS, .

142

I. MS Office Access 2007

- <Shift>
.
ADDRESS. SIGN.
ADDRESS "".

. ADDRESS , .

(. 3.12).

. 3.12.

.
, .
. ,

. ,
.
.
.

3.

143


. ,

. .
.

, , ,
, , , , .

, . , , Microsoft Access.

( )
, . ,
,
.


, . , Building
(Visible)
Visible.
:
Forms![Building].Visible.


. , , , .
:
IIF(expr; truepart; falsepart)

expr
ADDRESS ( + -

I. MS Office Access 2007

144

+ + ), ( + + + ).
FIRST (.
. 1.2).

Microsoft Access , True 1 ( ), False 0 (). Microsoft SQL Server


Bit (True , False ).

Microsoft Access
SQL Server, "" , True False,
Microsoft Access (
), Microsoft Access 2007
(. 3.13).

. 3.13.

3.

145

Trim(stringexpr), , Str(number), .
3.3
ADDRESS.
3.3.
=IIF([First]=;
Trim([street.Name]+' '+[Sign]+', '+(Trim([House]))+',.'+
Trim(Str([Flat])));Trim([Sign]+' '+[street.Name])+
', '+(Trim([House]))+', .'+Trim(Str([Flat])))

. 3.14 .
. , . . , .

.

. 3.14.

Microsoft Access ,
. , , .
,
, . .

I. MS Office Access 2007

146

3.6.1. Microsoft Access



. ,
, . ,
Cost ( ) Building 20 :
= [Forms]![Building]![Cost] * 1,2

.
! , , ( ). , ,
(=). .

, ,
(. 3.2).
3.2.

[Dwell]+[Branch]

[SquareFlat]-[Balcony]

-345

[Cost]*[Wear]

[Cost]/[Square]

[Year]\2

Mod

[Cost] Mod 12

[Line]^2

()

3.

147


( ), (. 3.3).
3.3.

>

5678>3000

>=

234>=2341

<

1000<1001

<=

6789<=6789

<>

567<>567


(. 3.4).
3.4.

And

""
()

And

And

""
()

Or

Or

Not

Not

Or

Not

3.6.2. Microsoft Access


. Microsoft
Access 2007 150 .
.

I. MS Office Access 2007

148

Microsoft Access 2007 ( ) Access VBA ( , ).


MS Access (. 3.5)
.
3.5.

Abs()

Abs(-345.6)

345.6

Atn()

Atn(1)

0.7853982

Cos()

Cos(1)

0.5403023

Exp()

Exp(1)

2.7182818

Int()


(. )

Int(-15.2)

16

Int(13.6)

13

Log()

Log(10)

2.302585

Rnd()

0 1

Rnd()

0.2895625

1 , 0 , 1

Sgn(-10.1)

Sgn(0)

Sgn(10.1)

Sgn()

()

Sin()

Sin(1)

0.8414710

10

Sqr()

Sqr(2)

1.4142136

3.

149

, ,
. 3.6.
3.6.

Date()

Date()

12.03.2008

Day()

Day(Date())

12

Month()

Month(Date))

Now()

Now()

12.03.2008
11:42:28

Time()

Time()

11:45:40

Year()

Year(Date())

2008

Chr()


, ANSI

Chr(37)

% ()

Lcase()

Lcase("aSD")

asd

Ucase()

Lcase("aSD")

ASD

10

Mid()


.
,

Mid("abcdef",2,3)

bcd

11

Rtrim()

Rtrim("abcd ")

abcd

I. MS Office Access 2007

150

3.6 ()

12

Ltrim()

Ltrim(" abcd")

abcd

13

Trim()

Trim(" abcd ")

abcd

14

Str()

Str(1234.56)

1234.56

15

Val()

Val("1234.56")

1234.56


MS Access 2007
Microsoft Access 2007 , 1992 . Microsoft, 2007 100 Access ,
. Access
, ( ), , , , Microsoft Access .
.

4.1.
Microsoft Access.
, !
, ,
. ,
,
.
, . , MS Access 2002, , .
:

I. MS Office Access 2007

152

1. MS Access 2007.
2. . Microsoft

Office Access ,
.
3. Office.

.
4.

. , .

2030 MS Access. , , .
12 . :
1. MS Access 2007 Office.
2. Access.
3. . .
4. -

4.2.
MS Access 2007

Microsoft Access 2000.
,

, .
(2000 20022003) Microsoft Access 2007 .

4. MS Access 2007

153

1. MS Access 2007.
2. . Microsoft

Office Access ,
.
3. Office. -

.
4. ,

, MS
Access 2007 .

MS Access 2007
(2000 20022003) .
, .

4.3.
Microsoft Access 2007 .
:
1. .
2. MS Access 2007

.
3. .

(. 4.1).
4. , .


: , .
,
, . , , , , .
,
. Microsoft Access 2007 -

154

I. MS Office Access 2007

"" "".
"" . .
, HOUSE flat .
104? : ,
.

. 4.1.

4.4.
accde-
Microsoft Visual Basic, accde- ,
, . Visual Basic - ,
, . , ,
.
accde-
:

4. MS Access 2007

155

, ,

;
,

;
Microsoft Access

VBA (accde-
);
, .

, ,
, accde-,
MS Access.

MS Access 2007.
Access, accde-,
, . , , accde. accde- , ,
, .
Microsoft Access , accde-, , . accde- Microsoft Access 2007
MS Access 2007, accde-,
MS Access accde- (
Microsoft - ).
Accde- accdb .
1. , accde.
2.

ACCDE.
3. ,

,
.

156

I. MS Office Access 2007

4.5. Microsoft Excel


, Microsoft Access.
MS Excel .

.
.
.
,
, 55 .

. 4.2.

:
1. Real Estate .

4. MS Access 2007

157

2. , -

Excel. HelpMe,
(. 4.2). 4.1.
3. .
4. . Excel.
5. Excel.
6. -


. OK.
7. Microsoft Excel 2007,

(. 4.3).

. 4.3. HelpMe,
Microsoft Excel 2007

4.1. SQL-

158

I. MS Office Access 2007

SELECT street.NAME, street.SIGN, building.HOUSE, flat.FLAT,


owners.FAMILY, owners.NAME, owners.SECOND, owners.BORN
FROM ((street INNER JOIN building ON street.STREET = building.STREET)
INNER JOIN flat ON (building.HOUSE = flat.HOUSE)
AND (building.STREET = flat.STREET))
INNER JOIN owners ON (flat.FLAT = owners.FLAT)
AND (flat.HOUSE = owners.HOUSE)
AND (flat.STREET = owners.STREET)
WHERE (((district.AREA)="")
AND ((owners.BORN)<=1950));

4.6.
Microsoft Access

Microsoft Access 2007.
, -

, Microsoft Access , .
, -

.

.
, .
.
, ,


. Windows, |
| | .
.

, ,
. Windows

4. MS Access 2007

159

, .
,

Windows, .

, , . .

4.7.
MS Access 2007 accdb. , "", .
, . , - , , MS Access
accdb.
, .
. :
1. , .
2. -

Access.

3. , , -

.
.

I. MS Office Access 2007

160

4. ,

,
.
5. .

, , ,
.
.

! , "-". , . (, , )
, .
""
"".

RealEstate_be.accdb.
"" RealEstate.accdb

(RealEstate_be.accdb)
, "" .
"". :
1. RealEstate.accdb ("").
2. .

. . , .
. . . "" !
3. . , <Shift>,

.
4. <Delete>.
5. .

4. MS Access 2007

161

6. . -

Access.
7. Access.
8. RealEstate_be.accdb (""). -

.
9.

. , "", "", .
10. (. 4.4) OK.
11. . c

"".

. 4.4.


, ,
. "".
111 .

MS
Access 2007 :
;

I. MS Office Access 2007

162

, ;
;
, ,

4.8.
MS Access 2007
(,
). , ,
. MS Access
, , , .
,
. :
(, , , ...);
( ,

) . , , ,
;
. -

;
. -

,
.
:
1. .
2. Office,

.
3. . (. 4.5).
4. ,

4. MS Access 2007

163

. 4.5. MS Office Access 2007


. ,
/, "" "". .

II

,
, ,


Visual Basic for Applications
Visual Basic for Applications (VBA)
. , , MS Visual C++, MS Visual C#,
MS VB, MS Visual FoxPro, Borland Delphi,
. VBA
Microsoft Office, AutoCAD, CorelDRAW . MS Office 2007 VBA 6.5. VBA,
Microsoft Access. .

5.1. Visual Basic for Applications


Real Estate, VBA . MS Access 2007,
Real Estate, . Visual Basic (. 5.1).
VBA , ,
, .
MS Access , VBA.
VBA Real Estate , . . 5.1
VBA. :
( : Project - sample);

168

II.

( , -

: General StartMainMenu);
(: Properties - ModuleMain);
(Immediate).

. .
, Properties .
. , , , . . .
(Alphabetic). (Categorized) .
VBA.
. VBA :
. ( )
( ),
.

. 5.1. Microsoft Visual Basic for Applications

5. Visual Basic for Applications

169

. , :
1. VBA Tools. -

.
2. Options. .
3. Procedure separator.

( . 5.1 General
StartMainMenu)
. VBA ,
, , .

5.2.

VBA (, , ). ,
(. 5.2).
, :
1. VBA Tools. -

.
2. Options. .
3. Auto Data Tips.

,
. <Ctrl>+<I>.

II.

170

. 5.2. VBA


<Enter>.
.
VBA
. - ,
VBA . <F1>.
.

5.3. ,
, . Visual Basic
for Applications .
, . ,
. .
:
;
, @, &, !, $, #;
255 ;
,

VBA.

5. Visual Basic for Applications

171

.
Dim, Public, Private Static. ,
. VBA
.
.
Public.

. VBA. :
Public Account As Integer

Account Integer.
.
. Dim

Private. .
, . "".
.
. :
Privat LastName As String
Dim LastName As String

LastName () String.
.
.

Static. .
, . , "".
Static, , . Dim, . :
Dim

Static Period As Long


Dim Period As long

Period Long.
.

. VBA.

II.

172

, Microsoft Access 2007:


1. , -

Visual Basic. .
2. Microsoft Visual Basic (. 5.3).

Debug .
3. . Debug.
4. .
5.

Immediate Window (Ctrl+G). Immediate ,


Debug.Print.

Proba,
ModuleSlave.
Proba.
Step Info (F8) . Debug.Print, Immediate .

. 5.3. Visual Basic for Applications

5. Visual Basic for Applications

173

VBA
.
. VBA , , , , , Variant.
, .
. 5.1 VBA. Byte,
Integer Long . Byte
. Currency ()
.
, Single Double.
5.1. Visual Basic for Applications

Byte

0 255

Integer

32 768 32 767

Long

2 147 483 648 2 147 483 647

Single

:
3.4028231038 1.4012981045
:
1.4012981045 3.4028231038

Double

:
1.7976931348623210308
4.9406564584124710324
:
4.9406564584124710324
1.7976931348623210308

Currency

922 337 203 685 477.5808


922 337 203 685 477.5807

Boolean

False True.

0, False. True.
True
1

II.

174

5.1 ()

Date

1 100 31
9999

Object

String

10

VBA Microsoft Access


2007 (. . 1.11).

:
Option Explicit

. , , , , .
. "". , ,
.
, . Visual Basic
for Applications , ,
. , . VBA , , . , :
Public Const Pi As Double=3.141592653589793

5. Visual Basic for Applications

175

,
, . VBA , .

5.4.
MsgBox()
Visual Basic for
Applications ,
. MsgBox()
VBA. 21 .
5.1
Real Estate, .
5.1.
Public Sub StopMenu()
'
' MS Access
If MsgBox(" Real Estate " _
& Chr(13) & " MS Access?", _
VbInformation+VbOKCancel+VbDefaulButton1, "") = VbOK Then
Application.Quit acQuitSaveAll

'

End If
End Sub

, ' , .
. .
(_) , .
VBA. , :
VbInformation + VbOKCancel + VbDefaulButton1
VbOK

II.

176

Visual Basic for Applications "", :


vbInformation=64

' (. 5.3)

vbOKCancel=1

' OK (. 5.2)

VbDefaulButton1=0

' (OK) (. 5.4)

OK (. 5.4), VbOK=1.

. 5.4.

MsgBox() ( 5.2),
.
5.2. VBA
If MsgBox(" Real Estate " _
& Chr(13) & " MS Access?", _
65, "") = 1 Then
Application.Quit acQuitSaveAll '
End If

:
;
VBA , -

, .
. 5.2 , MsgBox() . . 5.3 , . . 5.4 ,
, . 5.5 , .

5. Visual Basic for Applications

177

5.2.

VbOkOnly

VbOkCancel

VbAbortRetryIgnore

VbYesNoCancel

VbYesNo

VbRetryCancel

5.3.

VbCritical

16

VbQuestion

32

VbExclamation

48

VbInformation

64

5.4.

VbDefaultButton1

VbDefaultButton2

256

VbDefaultButton3

512

VbDefaultButton4

768

II.

178

5.5.

VbOk

VbCancel

VbAbort

VbRetry

VbIgnore

VbYes

VbNo

5.5.
VBA . VBA
150 . . 3.5 3.6. Microsoft Access 2007
Access VBA.
5.3 ,
VBA . , VBA. ,
.
. ( 5.4).
5.3.
Public Sub DemoSin()
'
'

5. Visual Basic for Applications

179

Static X As Single
Static y As Single
For X = 0 To 1 Step 0.1
y = Sin(X)
Debug.Print "=" & X & " Sin(X)=" & Y
Next X
End Sub
5.4. DemoSin
X=0

Sin(X)=0

X=0,1

Sin(X)=9,983342E-02

X=0,2

Sin(X)=0,1986693

X=0,3

Sin(X)=0,2955202

X=0,4

Sin(X)=0,3894183

X=0,5

Sin(X)=0,4794255

X=0,6

Sin(X)=0,5646425

X=0,7

Sin(X)=0,6442177

X=0,8

Sin(X)=0,7173561

X=0,9

Sin(X)=0,783327

VBA , , . , .
,
VBA. : Case, If, Sub, Step . .
, . ,
(. . 3.23.4).
, ,
(=). .

5.6.
, (, ,
. .), -

180

II.

. .
. ,
GrossSalary :
GrossSalary = 19800

10
(GrossSalary1, GrossSalary2,
GrossSalary3, ...), :
Dim GrossSalary(10) As Integer


. .
.
( ). , . Option Base 1,
. Dim
. ,
:
Dim GrossSalary(1 To 10) As Integer
GrossSalary(5)= 19800 '

. VBA ,
. 60 .
() Matric :
. .
Dim Matric(1 To 10, 1 To 10) As Integer

. Dim , .
ReDim. 5.5 ,
.
5.5.
Dim Sample() As Variant
' : , 5 (0:4) 6 (0:5)
'
ReDim Sample(4,5)

5. Visual Basic for Applications

181

'
Sample(0,2)= 3
Sample(1,3)= 8
'
Summary= Sample(0,2)+ Sample(1,3)
' . (1:11)
ReDim Sample(1 To Summary)
'
Sample(3)= ""

ReDim , , . VBA
. Sample
(1:12). Preserve.
Ubound .
ReDim Preserve Sample( Ubound(Sample) + 1)

5.7. Visual Basic for Applications


, ,
, , . . . 3.6.1
, . VBA
.

5.7.1.
, .
.
Sign 7.
Sign = 4
Sign = Sign + 3


Set. ( 5.6) cBar

II.

182

, Add () CommandBars ( ).
5.6.
Set cbar = CommandBars.Add(Name:="MainMenu", _
Position:=msoBarTop, MenuBar:=True, Temporary:=False)
' MainMenu -
' msoBarTop=1.
' MenuBar:=True

' MenuBar:=False -
' Temporary:=False -
'

5.7.2. With
With
.
With . .
With:
With oExcel.Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
EndWith

With:
oExcel.Selection.Borders(xlEdgeLeft).LineStyle = xlContinuous
oExcel.Selection.Borders(xlEdgeLeft).Weight = xlThin
oExcel.Selection.Borders(xlEdgeLeft).ColorIndex = xlAutomatic

5.7.3.
VBA ,
. , (, .)
. VBA

5. Visual Basic for Applications

183

, . , , .
If...Then , True, , Then.
If , . , If...Then,
:
If CountAvto=1 Then NewStatement= NewStatement+1

. ,
:
If CountAvto=1 Then
NewStatement= NewStatement+1
EndIf

If...Then...Else ,
Then, If True. ,
Else ( 5.7).
5.7. If...Then...Else
If QtyToHold > 0 Then
TransactionTypeHold = Hold_TransactionType
Quantity = QtyToHold
AddHold = EditTransactionOrderID
Quantity = QtyRequested
Else
QuantityGranted = 0
Account = Reseller
End If

Select Case If...Then...Else.


. Select Case ,
. , ,
( 5.8).

II.

184

5.8. Select Case


Select Case DomainFunction
Case DLookup
' DomainFunction
' DLookup
DomainFunctionWrapper = ExprDomainCriteria
QuantityGranted = 0
Account = Reseller
Case 14, 17
' DomainFunction 14 17
DomainFunctionWrapper = DomainCriteria
Account = Seller
Case 4 To 6
' DomainFunction 4 6
DomainFunctionWrapper = DSumExpr
Case Else
'
Debug.Assert False
End Select

Case,
.
Case,
, Else.

5.7.4.

. VBA , :
For...Next;
Do...Loop.

For...Next ,
. ,

5. Visual Basic for Applications

185

. ( 5.9) . .
5.9.
Option Base 1
Dim SampleArray (10,10,10) As Single
Dim i As Integer, j As Integer, k As Integer
Randomize
For i=1 To 10
For j=1 To 10
For k=1 To 10
SampleArray(i,j,k) = Rnd()
Next k
Next j
Next i

,
For Each...Next ( 5.10).
5.10. For Each...Next
Dim SampleArray (10,10,10) As Single
Dim ijk As Variant
Randomize
For Each ijk In SampleArray
'
ijk = Rnd()
Next

( 5.11)
For...To...Step...Next.
5.11.
Dim DemoArray(20) As Single
Dim i As Integer, Summa As Single
'
Summa = 0

II.

186

For i = 2 To UBound(DemoArray) Step 2


Summa = Summa + DemoArray(i)
Next

, , .
, ( 5.12). , CommandBars ( ), . Exit For.
5.12.
For Each cbar In CommandBars
If cbar.Name = "MainMenu" Then
' MainMenu .
'
Exit For
End If
Next cbar

Do ,
True ( While) True (
Until). :
Do While <>
<VisualBasicForAppication1>
Exit Do
<VisualBasicForAppication2>
...
Loop

:
Do Until <>
<VisualBasicForAppication1>
Exit DO
<VisualBasicForAppication2>
...
Loop

5. Visual Basic for Applications

187

Do
Exit Do, .
( 5.13)
, VBA. While...Wend. 110 ,
7. attempt
.
5.13.
Dim rank As Integer

'

Dim attempt As Integer

'

Randomize
rank = Int(10 * Rnd()) + 1
attempt = 1
While rank <> 7
attempt = attempt + 1
' 1 10
rank = Int(10 * Rnd()) + 1
Wend

5.7.5.
, VBA,
- . . ( 5.14). .
5.14.
Dim rank As Integer

'

Dim attempt As Integer

'

Randomize
For i = 1 To 10
' 1 10
rank = Int(10 * Rnd()) + 1
attempt = attempt + 1

188

II.

If rank = 7 Then GoTo LabelEnd


Next
LabelEnd: < VisualBasicForAppication>

5.8.
VBA
. VBA
Sub End Sub:
Sub <> (<1>, <2>, ...)
<VisualBasicForAppication1>
<VisualBasicForAppication2>
...
End Sub


. .
, "". VBA , ,
. ,
: ,
. .
.
.
.
, , . Account
( ):
Account 453, CountPages +1

VBA Call:
Call Account(453, CountPages +1)

VBA
: .
. , . , ,

5. Visual Basic for Applications

189

, .
ByRef. .
, ,
.
ByVal.
. ProcedureOptionsMain 5.15.
5.15.
Sub ProcedureOptionsMain()
Dim A As Integer
Dim B As Integer
Dim C As Integer
A = 1000
B = 2000
C = 3000
Call ProcedureOptionsSlave(A,B,C)
Debug.Print A
Debug.Print B
Debug.Print C
EndSub

. ,
. ProcedureOptionsSlave 5.16.
5.16.
Sub ProcedureOptionsSlave(ByRef X, ByVal Y, Z)
X = X + 1
Y = Y + 1
Z = Z + 1
Debug.Print X
Debug.Print Y
Debug.Print Z
EndSub

190

II.

. -. . . , ProcedureOptionsSlave: 1001, 2001 3001. ,


: 1001, 2000 3001.
, , ByVal ( ), .
VBA, VBA, .
Function End Function.
Function <> (<1>, <2>, ...)
<VisualBasicForAppication1>
<VisualBasicForAppication2>
...
<> = <>
End Function

VBA,
:
Call <> (<__>)

: VBA , MS
Office Access 2007.
CurrentPath ModuleSlave. , ( 5.17). Login
.
5.17.
Public Function CurrentPath() As String
'
' ,
Dim NameBase As String
Dim NameBaseShort As String
Dim CountLetter As Integer

5. Visual Basic for Applications

191

' ,
NameBase = CurrentDb.NAME
'
' Dir() - VBA
NameBaseShort = Dir(NameBase)
' , ,
' \
CountLetter = Len(NameBase) - Len(NameBaseShort) - 1
Debug.Print " : " & NameBase
Debug.Print " : " & Len(NameBase) & " "
Debug.Print " : " & NameBaseShort
Debug.Print " : " & Len(NameBaseShort) & " "
' CountLetter
' Left() - VBA
CurrentPath = Left(NameBase, CountLetter)
End Function

: NameBase, NameBaseShort
CountLetter. , , , , .
CurrentPath
. Debug.Print
.
ModuleSlave CurrentPath.
Debug Visual
Basic. .
Debug. .
Immediate Window (Ctrl+G). Immediate :
Debug.Print CurrentPath

? CurrentPath

Immediate (. 5.5).

II.

192

. 5.5. CurrentPath


, . ,
CountLetter :
CountLetter = 32

, Immediate,
. ,
. . "".
For CountLetter=1 To 5: Debug.Print CountLetter: Next CountLetter

Debug.Print .
Immediate, , .
,

:
Public Const Debugging = True

If End If:
If Debugging Then
Debug.Print " : " & NameBase
Debug.Print " : " & Len(NameBase) & " "
Debug.Print " : " & NameBaseShort
Debug.Print " : " & Len(NameBaseShort) & " "
End If


True False.

SQL Access
SQL (Structured Query Language) , .

. SQL
,
.
,
, -
SQL.
SQL-.
, . .
, , SQL. ,
- , . .
.

6.1. SQL
SQL :
, ;
, ,

;
.

II.

194

SQL, , . :
DML (Data Manipulation Language)

;
DDL (Data Definition Language) -

.
SQL MS Access .

. , , ,
, .
, SQL
, ,
.

6.2. .
SELECT
SELECT DML
(INSERT, UPDATE DELETE) ,
,
. SQL Real Estate.
SELECT MS Access 2007
. :
SELECT <_>
FROM <_>
[WHERE <_>]
[GROUP BY <__>]
[HAVING <>]
[ORDER BY <_>]

. , , , . .
.

6. SQL Access

195

6.2.1. FROM
FROM , .
tblStreet Real Estate :
SELECT Street, Name, Sign, First
FROM tblStreet;

II III , ,
"tbl". ,
, . .
. "qwr".

MS Access SQL-.
. :
1. MS Access 2007.
2. .

.
3. . .
4. SQL.
5. SQL.
6. " " .

" " . ! (. 6.1).

. 6.1.

II.

196

MS Access .
, .
(. 6.2).

. 6.2.

(1032 ) tblStreet. SELECT (*). :


SELECT * FROM tblStreet;

6.2.2. WHERE
SELECT ,
WHERE, , , SELECT. WHERE , . ,
, WHERE, .
,
(Family) , tblOwners, :
SELECT Family, Name, Second FROM tblOwners
WHERE Family = ''
ORDER BY Name, Second;

79 (. 6.3). Name () Second ().

6. SQL Access

197

. 6.3. 79

6.2.3. ORDER BY
, , , , - . SQL ORDER
BY, .
.
ORDER BY .
, , ,
SELECT. . .
/ .
, .

6.2.4. DISTINCT
SQL- .

DISTINCT. :
SELECT DISTINCT Family, Name, Second FROM tblOwners
WHERE Family = ''
ORDER BY Name, Second;

71 . , SELECT. ,

198

II.

, SQL
, . ,
.
? .
,
!

6.2.5. TOP
,
. :
SELECT DISTINCT TOP 10 Family, Name, Second FROM tblOwners
WHERE Family = ''
ORDER BY Name, Second;

10 , (DESC ):
SELECT DISTINCT TOP 10 Family, Name, Second From tblOwners
WHERE Family = ''
ORDER BY Name, Second DESC;

ORDER BY, 10 tblOwners, WHERE.


PERCENT
,
ORDER BY.

6.2.6. GROUP BY
,
, :
SELECT <_>
FROM <_>
[GROUP BY <__>]

6. SQL Access

199

:
SELECT Family, Name, Second FROM tblOwners
WHERE Family = ''
GROUP BY Family, Name, Second
ORDER BY Name, Second;

, , ,
. 71 79 ,
tblOwners. , . . :
SELECT DISTINCT Family, Name, Second FROM tblOwners
WHERE Family=''
ORDER BY Name, Second;

.
. , , .
.

6.2.7. HAVING
, SELECT GROUP BY. GROUP BY, HAVING ,
.
:
SELECT Family, Name, Second, Count(Family) AS
FROM tblOwners
WHERE Family = ''
GROUP BY Family, Name, Second
HAVING Count(Name)>1 AND Count(Second)>1
ORDER BY Name, Second;

79 7 , " " (. 6.4).


. Count().
. .
,

II.

200

, SQL. , .

. 6.4.

6.2.8.
.
, .
. .
10
100 , .
MS Access .
WHERE, INNER-JOIN-ON.
: tblBuilding tblStreet, :
SELECT tblStreet.Name, tblStreet.Sign,
tblBuilding.House, tblBuilding.Year
FROM tblStreet, tblBuilding
WHERE tblstreet.Street=tblbuilding.Street
ORDER BY Year;

6. SQL Access

201

. 6.5. tblBuilding (334 ). .


344 688
(334 1032 ).

. 6.5.

.
199. ! .
FROM-INNERJOIN-ON:
SELECT tblStreet.Name, tblStreet.Sign,
tblBuilding.House, tblBuilding.Year
FROM tblStreet INNER JOIN tblBuilding
ON tblStreet.Street=tblBuilding.Street
ORDER BY Year;

, ! . . tblBuilding.

.
SQL .

II.

202

MS Access 2007 SELECT


. :
FROM (...(1 INNER JOIN 2 ON 1) INNER JOIN
(3 ON 2) INNER JOIN
(4 ON 3) INNER JOIN ...)

4
.
MS Excel. . ,
.
( NAME tblStreet)
( NAME tblOwners). ,
,
MS Access .
, , .
(, , ) (,
, ) .
SQL
.
: AS <>, &.
SQL- 6.1. . 6.6
. 206.
6.1.
SELECT tblOwners.FAMILY & ' ' & tblOwners.NAME & ' ' &
tblOwners.SECOND AS , tblStreet.NAME & ' ' &
Lcase(tblStreet.SIGN) & ' ' & tblBuilding.HOUSE &
' , .' & tblFlats.FLAT AS , tblOwners.BORN
AS [ ]
FROM ((tblStreet INNER JOIN tblBuilding ON
tblStreet.STREET=tblBuilding.STREET)
INNER JOIN tblFlats ON
(tblBuilding.STREET=tblFlats.STREET) AND
(tblBuilding.HOUSE=tblFlats.HOUSE))

6. SQL Access

203

INNER JOIN tblowners ON


(tblFlats.STREET=tblOwners.STREET) AND
(tblFlats.HOUSE=tblOwners.HOUSE) AND
(tblFlats.FLAT=tblOwners.FLAT)
WHERE Year(tblOwners.BORN)<1940 AND
tblBuilding.DISTRICT=1
ORDER BY tblOwners.FAMILY;

. 6.6.

6.2.9.
SELECT, , , .
WHERE HAVING
.
SQL
tblFlats, . 6.2.
6.2.
SELECT *
FROM tblFlats

II.

204
WHERE NOT EXISTS
(SELECT * FROM tblOwners

WHERE Street=tblFlats.Street AND


House=tblFlats.House AND
Flat=tblFlats.Flat)
ORDER BY Street, House, Flat;

: NOT EXIST.
.
True False.
tblOwners. ( ) EXIST.
9 18 475 txtFlats. , .
, . . .
( 6.3).
6.3.
SELECT tblStreet.Name, tblStreet.Sign, tblFlats.House,
tblFlats.Flat, tblFlats.Rooms
FROM tblStreet INNER JOIN tblFlats ON
tblStreet.Street=tblFlats.Street
WHERE NOT EXISTS
(SELECT * FROM tblOwners
WHERE Street=tblFlats.Street AND
House=tblFlats.House AND
Flat=tblFlats.Flat)
ORDER BY Name, House, Flat;

. 6.7 ,
.
EXIST NOT EXIST Microsoft Access Count(*). *,
( 6.4).

6. SQL Access

205

. 6.7.

6.4. Count(*) EXIST


SELECT tblStreet.Name, tblStreet.Sign, tblFlats.House,
tblFlats.Flat, tblFlats.Rooms
FROM tblStreet INNER JOIN tblFlats ON
tblStreet.Street=tblFlats.Street
WHERE 1>
(SELECT Count(*) FROM tblOwners
WHERE Street=tblFlats.Street AND
House=tblFlats.House AND
Flat=tblFlats.Flat)
ORDER BY Name, House, Flat;

Count(*)
, EXIST.

6.3.
DML (Data Manipulation Language), SQL (Structured
Query Language), .
: SELECT, INSERT, UPDATE DELETE.

II.

206

SELECT
.
.

6.3.1. INSERT
,
.
( ) :
INSERT INTO <_>
SELECT <>

( ) :
INSERT INTO <_>
[(1[, 2[, ...]])]
VALUES (1[, 2[, ...])


. Building
tblBuilding :
INSERT INTO tblBuilding
SELECT * FROM Building

INSERT SELECT, .
.

. .
, . tblStreet
:
INSERT INTO tblStreet
(NumSTREET, Name, Sign, [First])
VALUES (1033, ' ', '', False);

:
INSERT INTO tblStreet
VALUES (1033, ' ', '', False);

6. SQL Access

207

First ( ) MS Access 2007 , . . Access SQL


.

6.3.2. UPDATE
. UPDATE :
UPDATE <_>
SET 1=1]
[,2=2]
[ ...]
WHERE <_>

UPDATE
, , . .
, ,
. .
,
.
tblUser:
UPDATE tblUser SET LastName = ""
WHERE LastName= "";

FLATS ( ) . tblFlats (). :


UPDATE tblBuilding
SET flats =
(SELECT Count(*) FROM tblFlats
WHERE Street=tblBuilding.Street
AND House=tblBuilding.House);

II.

208

, . SQL Access
SET, Flats tblBuilding
, :
:
UPDATE tblBuilding SET Flats = DCountSQL(Street,House);

DCountSQL ( 6.5) -

ModuleSlave.
DCountSQL DCount(), .
tblFlats (), . :
DCount(, [, ])

. , . ,
. (*).
DCount() , Null.

. , , .
, . tblFlats.

. ,
, DCount().
, WHERE SQL, WHERE. ,
DCount() .
, , . DCount() Null.

Count()
. Count() DCount(), , . DCount(),
.

6. SQL Access

209

.
- ,
, , , Null .

6.5. DCountSQL
Public Function DCountSQL(NumberStreet, NumberHouse) As Integer
'
' NumberStreet -
' NumberHouse

DCountSQL = DCount("*", "tblFlats", _


"Street = " & NumberStreet & _
"AND House = " & NumberHouse)
End Function

.
SET , MS Access
! , .
:
UPDATE tblBuilding SET Flats = CountSQL(Street,House);

VBA : Microsoft ActiveX Data

Objects 2.1 Library ( : Tools | References).


CountSQL ( 6.6)

ModuleSlave.
6.6. CountSQL
Public Function CountSQL(NumberStreet, NumberHouse) As Integer
'
' NumberStreet -
' NumberHouse

Dim CountSelectSQL As Integer

'

'
Dim CN As ADODB.Connection

II.

210

' CN - -
' ADO
Dim RS As ADODB.Recordset
' RS - -
Set CN = CurrentProject.Connection

'

Set RS = New ADODB.Recordset

'

With RS
' RS (Recordset)
' : SQL-
.Source = "SELECT * FROM tblFlats " & _
"WHERE Street = " & NumberStreet & _
" AND House= " & NumberHouse
'
.ActiveConnection = CN
.CursorType = adOpenKeyset

'

' RS
'
.Open
End With
CountSelectSQL = RS.RecordCount
' RecordCount - RS
'
'
Set RS = Nothing
Set CN = Nothing
'
' CountSQL - -
CountSQL = CountSelectSQL
End Function

VBA-. Visual Basic


,
,
. ADO (ActiveX
Data Objects), ,
Visual Basic for Applications.

6. SQL Access

211

6.3.3. DELETE
, .
DELETE :
DELETE
FROM <_>
WHERE <_>

DELETE ,
. , EXECUTE DROP.
.
DELETE , ,
, .

, , . ,
.

6.4. SQL
MS Access
. 1.
"", DDL (Data Definition
Language).
DDL, , :
CREATE TABLE ;
ALTER TABLE ;
DROP ;
CREATE INDEX .

, , .

II.

212

6.4.1. . CREATE TABLE


. .
INSERT. CREATE TABLE . . , , .
CREATE TABLE :
CREATE [TEMPORARY] TABLE <_>
(1 1 [(1)] [CONSTRAINT <1>]
[(2 2 [(2)] [CONSTRAINT <2>]
[ ...]]
[ CONSTRAINT <__> [, ...]])

CREATE TABLE , . 6.1.


6.1.

1, 2

, .

1, 2

1, 2

(
TEXT,BINARY STRING)

1, 2

CONSTRAINT,

__

CONSTRAINT,

, TEMPORARY, , .
.
.

6. SQL Access

213

, CREATE
TABLE MS Office Access 2007 . 6.2.
6.2. , SQL
MS Access 2007

BYTE

SMALLINT=SHORT

INTEGER=LONG

SINGLE

NUMERIC= FLOAT=DOUBLE

CHAR(N)=TEXT(N)=STRING(N)

N-

BINARY(N)

(N-)

DATE=DATETIME

CURRENCY

LOGICAL=BIT

tabStreet ( ). . 6.8. NumStreet ( )


(NumStreet PRIMARY KEY).
CREATE TABLE tabStreet
(NumStreet SMALLINT CONSTRAINT NumStreet PRIMARY KEY,
Name CHAR (30),
Sign CHAR(10),
First LOGICAL)

tabStreet "--"
tabBuilding (. 6.9).
tabBuilding. SQL:
CREATE TABLE tabBuilding
(NumStreet SMALLINT CONSTRAINT NumStreet REFERENCES tabStreet,

214

II.

House SMALLINT,
Land SINGLE,
Elevator LOGICAL,
CONSTRAINT NumStreetAndHouse PRIMARY KEY (NumStreet, House))

. 6.8. tabStreet

. 6.9. tabBuilding

6. SQL Access

215

NumStreet ( ).
(CONSTRAINT NumStreet) (REFERENCES)
tabStreet.
NumStreetAndHouse tabBuilding : NumStreet +
House. tabStreet
. . . 6.10 SQL.

. 6.10. "--"

6.4.2. .
ALTER TABLE
ALTER TABLE , CREATE TABLE
. , , . . ALTER TABLE
:
ALTER TABLE <_>
ADD [COLUMN] <_> [()][NOT NULL]
[CONSTRAINT <>]

II.

216

ALTER COLUMN <_> [()]


DROP [COLUMN] <_>
[CONSTRAINT <_>]
[ CONSTRAINT <__> [, ...]])

CREATE TABLE (. 6.3).


6.3.

, ,

( TEXT,BINARY STRING)

__

CONSTRAINT,

ADD COLUMN
. , , TEXT, BINARY STRING.
NOT NULL,
.
ALTER COLUMN
. , ,
TEXT, BINARY STRING.
ADD CONSTRAINT . DROP COLUMN . . DROP CONSTRAINT .
CONSTRAINT.

6. SQL Access

217

, CREATE INDEX. , ALTER TABLE CREATE INDEX,


ALTER TABLE DROP.

NOT NULL CONSTRAINT .


NOT NULL . .

tblBuilding, Real
Estate. FLATS ( ). :
ALTER TABLE tblBuilding
ADD FLATS SHORT;

6.4.3. .
DROP
DROP , .
DROP:
DROP TABLE <_>
DROP INDEX <> ON <_>
DROP PROCEDURE <_>
DROP VIEW <_>

DROP . 6.4.
6.4. DROP

II.

218

6.4 ()

.
ALTER
TABLE.

6.4.4. .
CREATE INDEX
CONSTRAINT CREATE TABLE ALTER TABLE
.

CREATE INDEX.
CREATE INDEX :
CREATE [ UNIQUE ] INDEX <_>
ON <_> (1 [ASC|DESC]
[, 2 [ASC|DESC], ...])
[WITH { PRIMARY | DISALLOW NULL | IGNORE NULL }]

CREATE INDEX . 6.5.


6.5.

1, 2

6. SQL Access

219

UNIQUE .
,
WITH.
:
-

;
,

;
DESC,

.
DISALLOW NULL .
IGNORE NULL .
PRIMARY . UNIQUE
.

, PRIMARY . .


. .
. , , . , , .
.
. ,
.

7.1.
Windows- .
, ,
. Windows . -
Windows. , . -, . -,
, -, .

7.

221

,
.
.
.

, ,
.
. ,
.
, Stage (), . , , ( )
, . . " ",
. , .
. . 7.1

Real Estate. , , ,
.
, . , ,
. .
( ), , .

222

II.

7.

223


, . , . ,
.
:
;
;
, ;
;
;
;
.

Real Estate, . ,
,
, . , . .
, ,
. . , .

. . 7.1 . ,

. ,
.
,
, .
, .
, , .

224

II.

7.2.
,
. ,
,
. .
:
, .
Microsoft Office Access 2007
, , ,
.
.
,
,
.

Microsoft Access .
,
, (
) . ,
, , ,
. .
"" MS Access 2007, ,
, , Access 2007.
,
Microsoft
Access. VBA. . 7.2
, .
Microsoft Access 2007 .
.

7.

225

. 7.2. Real Estate

,
.
,
. ,
, . ,
.
, Real Estate,
7.1.
7.1.
Public Sub StartMainMenu()
' RealEstate.accdb
'
' c cbar.
Dim cbar

As CommandBar

' Exist.
Dim Exist As Boolean
'
For Each cbar In CommandBars
cbar.Enabled = False
Next cbar

II.

226
Exist = False

'

Exist

For Each cbar In CommandBars


If cbar.NAME = "MainMenu" Then
' MainMenu
'
'
Exist = True
' Exist True
Exit For
End If
Next cbar
If Not Exist Then
' Exist False
'
'
Set cbar = CommandBars.Add(NAME:="MainMenu", _
Position:=msoBarTop, MenuBar:=True, Temporary:=False)
' MainMenu
' MenuBar:=True

' MenuBar:=False
' Temporary:=False
'
End If
cbar.Enabled = True

'

cbar.Visible = True

'

With cbar
With .Controls
With .Add(Type:=msoControlPopup)
' Popup-
'
.Caption = ""
With .Controls
'
With .Add(Type:=msoControlButton)
'
.Caption = " "

7.
.Enabled = ChangePicture
'
' ChPicture
' ModuleSlave
.OnAction = "ChPicture"
'
.TooltipText = " "
End With
With .Add(Type:=msoControlButton)
'
.Caption = " "
.Enabled = ChangePassword
'
' Password
' ModuleSlave
.OnAction = "Password"
'
.TooltipText = " "
End With
With .Add(Type:=msoControlButton)
.Caption = "-"
.Enabled = True
.OnAction = "Calendar"
.TooltipText = " "
End With
With .Add(Type:=msoControlButton)
.Caption = ""
.Enabled = True
.OnAction = "Calculator"
.TooltipText = " "
End With
With .Add(Type:=msoControlButton)
.Caption = ""
.Enabled = True
.OnAction = "StopMenu"
End With
End With
End With

227

II.

228

With .Add(Type:=msoControlPopup)
.Caption = ""
With .Controls
With .Add(Type:=msoControlButton)
.Caption = " "
.Enabled = True
.OnAction = "Autor"
End With
With .Add(Type:=msoControlPopup)
.Caption = " "
With .Controls
With .Add(Type:=msoControlButton)
.Caption = ""
.Enabled = True
.OnAction = "Shot"
End With
With .Add(Type:=msoControlButton)
.Caption = ""
.Enabled = True
.OnAction = "Long"
End With
End With
End With
With .Add(Type:=msoControlButton)
.Caption = " "
.Enabled = RightAccess
.OnAction = "Access"
End With
With .Add(Type:=msoControlButton)
.Caption = " "
.Enabled = True
.OnAction = "Absolutely"
End With
End With
End With
With .Add(Type:=msoControlPopup)
.Caption = ""

7.
With .Controls
With .Add(Type:=msoControlButton)
.Caption = " "
.Enabled = SeekBuilding
.OnAction = "Search"
End With
With .Add(Type:=msoControlButton)
.Caption = " "
.Enabled = AddBuilding
.OnAction = "AddBuild"
End With
End With
End With
With .Add(Type:=msoControlPopup)
.Caption = ""
With .Controls
With .Add(Type:=msoControlButton)
.Caption = " "
.Enabled = StreetTown
.OnAction = "Street"
End With
With .Add(Type:=msoControlButton)
.Caption = " "
.Enabled = DistrictTown
.OnAction = "District"
End With
With .Add(Type:=msoControlButton)
.Caption = " "
.Enabled = MaterialWall
.OnAction = "Wall"
End With
With .Add(Type:=msoControlButton)
.Caption = ""
.Enabled = Staff
.OnAction = "Employee"
End With
End With
End With

229

II.

230

With .Add(Type:=msoControlButton)
.Style = msoButtonCaption
.Caption = ""
.Enabled = True
.OnAction = "StopMenu"
End With
End With
End With
End Sub

7.3. VBA
VBA . , , , .
: . , VBA? . . . , ,
"" . VBA (Project Explorer).


"Form_" "Report_" . Project Explorer
.

StartMainMenu ModuleMain . :
1. Microsoft Access 2007.
2. , -

Visual Basic. .
3. Microsoft Visual Basic.

Insert.

7.

231

4. . Module. -

(. 7.3).

. 7.3. Microsoft Visual Basic for Applications

5.

Visual Basic File. .


6.

Save Real Estate 2007. (. 7.4). ModuleMain.


.
Public, .
StartMainMenu ,
- .

. 7.4. VBA

II.

232

, MS Access 2007 ,
VBA. :
1. Microsoft Access 2007.
2. . .
3. .

, , .
4. : , .
5. . VBA

.
6. VBA. .
7. OK.

Microsoft Access 2007


. 7.2.
7.2.
Public Sub ResetMainMenu()
'
Dim cbar As CommandBar
' ,
For Each cbar In CommandBars
If cbar.Name = "MainMenu" Then
CommandBars("MainMenu").Delete
Exit For
End If
Next cbar
'
Dim Bar As CommandBar
'
For Each Bar In CommandBars
Bar.Enabled = True
Next Bar
End Sub

7.

233

7.4.

Real Estate - (. . 2.42).
Start. I. . ,
. 7.3.
7.3.
Private Sub 2_Click()
'
DoCmd.Close

'

StartMainMenu

'

End Sub


. Login. . 7.4.
7.4.
Private Sub 2_Click()
'
On Error GoTo Err_2_Click
Dim stDocName As String
Dim stLinkCriteria As String
DoCmd.Close

'

stDocName = "Login"
DoCmd.OpenForm stDocName, , , stLinkCriteria
Exit_2_Click:
Exit Sub
Err_2_Click:
MsgBox Err.Description
Resume Exit_2_Click
End Sub

234

II.

7.4.1.

Login . . Microsoft Access 2007 Office,
Access.
. 7.5.

. 7.5.

. ,
. 7.2.
,
Microsoft Access 2007,
Access, , Microsoft
Access 2007. <Shift>. , . <Shift> ,
.

7.

235

7.4.2. <Shift>
MS Access 2007 <Shift>, Visual Basic,
AllowBypassKey False.
, MS Office Access 2007,
SetBypassProperty ( 7.5),
AllowBypassKey, ,
CreateProperty, Properties.
7.5. AllowBypassKey
Sub SetBypassProperty()
Const DB_Boolean As Long = 1
ChangeProperty "AllowBypassKey", DB_Boolean, False
End Sub
Function ChangeProperty(strPropName As String, _
varPropType As Variant, _
varPropValue As Variant) As Integer
Dim dbs As Object, prp As Variant
Const conPropNotFoundError = 3270
Set dbs = CurrentDb
On Error GoTo Change_Err
dbs.Properties(strPropName) = varPropValue
ChangeProperty = True
Change_Bye:
Exit Function
Change_Err:
If Err = conPropNotFoundError Then ' Property not found.
Set prp = dbs.CreateProperty(strPropName, _
varPropType, varPropValue)
dbs.Properties.Append prp
Resume Next

II.

236
Else
' Unknown error.

ChangeProperty = False
Resume Change_Bye
End If
End Function

<Shift>
:
1. SetBypassProperty -

( Real Estate ModuleShiftLock).


2. VBA.
3. Immediate SetBypassProperty.
4. .


, .
, . True AllowBypassKey.

7.4.3.
-
Microsoft
Access 2007. .
.

"" . :
Private Sub Form_Load()
' MS Access 2007
Application.SetOption "ShowWindowsInTaskbar", False
End Sub

7.

237

7.4.4.

(. 7.6) Microsoft Office 12.0 Object Library (. 7.7). :
1. MS Access 2007. -

.
2. Visual Basic, ,

.
3. VBA Tools. .
4. References. -

.
5. Microsoft Office 12.0 Object Library.
6.

: Microsoft Office 12.0 Access Database Engine


Object Library.
7. .

. 7.6.

II.

238

. 7.7. Microsoft Office 12.0 Object Library

7.4.5.

Visual Basic for Applications ,
Microsoft Access, -
. Microsoft Office
.
.
:
1. Microsoft Access 2007 Office.

Office.
2. Access.

.
3.

. .
4. .
5. .
6. (. 7.8)

....

,
. accdb. MS Office Access 2007.

7.

239

. 7.8. VBA

7.5.

, II III,
. ,
. . (, , , , . .)
. :
1. - MS Office Access 2007.
2. .
3. MS Access .
4.

. . Access.

5. - Access.
6. . -.



, ,
,
.
, - ,
- .
, . .
.

. : .

8.1.


, (). . . -

8.

241

, . . ,
, . , , ,
.

8.2.



.
,
( , ,
. .), .
.
Real Estate
( Login Employee). ,
.
( ( )
Employee).
.
. 8.5
Employee.

242

II.

8.3.

, .
, , , , . , ,
.
, ,
.

, (), .
Real Estate Login.
, ( ) , .

. 8.1.

8.

243

Login (. 8.1).
, Microsoft Access. , . MS Access 2007
.
.
Access (. . 7.5)
Login. .
, ,
Login . Windows .
MS Access 2007 . Form1.
I.
Login (. 8.2).
Real Estate Login.
. .
. . . . .
: , , , .

II.

244

. 8.2.

. . . . 8.1.
8.1. Login

-
SharePoint

10

8.

11

245

MS Access
, , .
MS Access , , ,
. ,
Access . .
:
1.

(Form_Open).

2.

(Form_Load).

3.

(Form_Resize).

4.

(Form_Activate).

5.

(Form_Got Focus).

: (Form_Open) (Form_Load)
,
. 8.1 8.2.
8.1. Login
Private Sub Form_Open(Cancel As Integer)
' ,
'
'
Adjustment ' ModuleMain
End Sub

8.2. Login
Private Sub Form_Load()
'
Me.HelpFile = CurrentPath() & "\RealEstate.chm"
End Sub

246

II.

RealEstate.chm - .
CurrentPath()
. Adjustment
ModuleMain 8.3.
8.3. Adjustment
Public Sub Adjustment()
'
FAMILY = " "
SuperVisor = False

'

ChangePicture = False

'

ChangePassword = False

'

SetDeleted = False

'

CountRecords = False

'

RightAccess = False

'

SeekBuilding = False

'

AddBuilding = False

'

WorkFlats = False

'

AccountWork = False

'

WordExcel = False

'

StreetTown = False

'

DistrictTown = False

'

MaterialWall = False

'

Staff = False

'

End Sub

Login tblUser,
Real Estate. tblUser . 8.2.
LastName + FirstName +
SecondName. ,
,
.
.
8.2.

8.

247

LastName

15

FirstName

12

SecondName

10

Post

25

PassWord

10

File

Access01

Access02

8.2 ()

Access03

10

Access04

11

Access05

12

Access06

13

Access07

14

Access08

15

Access09

16

Access10

II.

248

17

Access11

18

Access12

19

Access13

20

Access14

21

Inspector

15

22

Date_up

23

Time_up

10

24

Range

Access01Access14 Login, , False


True, , .
-
. ( ),
:
With .Add(Type:=msoControlPopup)
.Caption = ""
With .Controls
With .Add(Type:=msoControlButton)
.Caption = " "
.Enabled = StreetTown
.OnAction = "Street"
End With
With .Add(Type:=msoControlButton)
.Caption = " "
.Enabled = DistrictTown
.OnAction = "District"
End With

8.

249

End With
End With

StreetTown, DistrictTown
Enabled,
. , "" CommandAdd
AddBuilding. :
Private Sub Form_Load()
CommandAdd.Enabled = AddBuilding
End Sub


, .
.

.
.

. 8.3 ComboBox.
.
tblUser. 24. ,
.
Select * from tbtlUser .
.
8.3.

ComboBox

2,5;2,5

Select * from tblUser

II.

250

10

TAB


tblUser. , ( 22 23).
, . (1 2 ). .
0 .
. 5, : 2,5;2,5.
. .

(, , , . .)
. ComboBox.
txtFirstName ( ) :
=[ComboBox].[Column](1)

MS Access .
, , . .
. ComboBox
, txtFirstName .
(
) PictureUser :
=CurrentPath() & "\PHOTO\" & [ComboBox].[Column](5) & ".jpg"

:
CurrentPath()

;
PHOTO , ;

8.

251

tblUser. File ( );
JPG .

Login , :
1. MS Access 2007


.
2. -

ComboBox. .
3. .
4. .
5. .

VBA 8.4.
8.4.
Private Sub ComboBox_GotFocus()
' Dropdown
'
ComboBox.Dropdown
End Sub

txtHint ()
:
=UnKod([ComboBox].[Column](4))

.
.

. . . .

II.

252

PassWord tblUser. CrKod(),


UnKod(). 8.5 8.6.
8.5.
Public Function CrKod(cPassword) As String
'
' cPassword - ( )
Dim cLetter As String

'

Dim cEncryptedPassword As String

'

Dim i As Integer

'

If Not IsNull(cPassword) Then


'
'
cPassword = Trim(cPassword)
'
cEncryptedPassword = ""
For i = 1 To Len(cPassword)
'
cLetter = Mid(cPassword, i, 1)
cEncryptedPassword = cEncryptedPassword + _
Chr(Asc(cLetter) - i)
Next i
End If
'
CrKod = cEncryptedPassword
End Function

8.6.
Public Function UnKod(cEncryptedPassword) As String
'
' cEncryptedPassword -
' ( )
Dim cLetter As String

'

Dim cPassword As String

'

Dim i As Integer

'

8.

253

If Not IsNull(cEncryptedPassword) Then


'
'
cEncryptedPassword = Trim(cEncryptedPassword)
'
cPassword = ""
For i = 1 To Len(cEncryptedPassword)
'
cLetter = Mid(cEncryptedPassword, i, 1)
cPassword = cPassword + Chr(Asc(cLetter) + i)
Next i
End If
'
UnKod = cPassword
End Function

VBA:
Mid() , i

;
Chr() , ANSI-;
Asc() ANSI- ;
Trim() .

. . .
txtParole () .
.
. .
Login "" (*).
. :
1. Login .
2.

II.

254

3. ,

.
.
4. , , -

,
. .
5. . -

Click ( ) .
8.7 8.8 .
8.7. Click
Private Sub 2_Click()
'
Dim Parole As String

'

Dim ParoleEnter As String

'

If IsNull([Forms]![Login]![ComboBox].Column(0)) Then
' - Null
'
MsgBox " .", _
vbOKOnly + vbExclamation, ""
Exit Sub
End If
' tblUser
' ComboBox.
'
Parole = [Forms]![Login]![ComboBox].Column(4)
'
Parole = Trim(Parole)
If Len(Trim(Parole)) = 0 Then
' tblUser
' (, ODBC)
SuperVisor = False

'

MsgBox " ." _


& Chr(13) & " " & _

8.
" ", _
vbOKOnly + vbExclamation, ""
Application.Quit acQuitSaveAll '
Else
If IsNull([Forms]![Login]![txtParole]) Then
' - Null
MsgBox " .", _
vbOKOnly + vbExclamation, ""
'
'
[Forms]![Login]![txtParole].SetFocus
Exit Sub
End If
'
ParoleEnter = Trim([Forms]![Login]![txtParole])
'
ParoleEnter = CrKod(ParoleEnter)
'
FAMILY = [Forms]![Login]![ComboBox].Column(0)
If ParoleEnter = Parole Then
SuperVisor = True

'

'
'
ChangePicture = [Forms]![Login]![ComboBox].Column(6)
'
ChangePassword = [Forms]![Login]![ComboBox].Column(7)
'
SetDeleted = [Forms]![Login]![ComboBox].Column(8)
'
CountRecords = [Forms]![Login]![ComboBox].Column(9)
'
RightAccess = [Forms]![Login]![ComboBox].Column(10)
'
SeekBuilding = [Forms]![Login]![ComboBox].Column(11)
'
AddBuilding = [Forms]![Login]![ComboBox].Column(12)
'
WorkFlats = [Forms]![Login]![ComboBox].Column(13)
'

255

II.

256

AccountWork = [Forms]![Login]![ComboBox].Column(14)
'
WordExcel = [Forms]![Login]![ComboBox].Column(15)
'
StreetTown = [Forms]![Login]![ComboBox].Column(16)
'
DistrictTown = [Forms]![Login]![ComboBox].Column(17)
'
MaterialWall = [Forms]![Login]![ComboBox].Column(18)
'
Staff = [Forms]![Login]![ComboBox].Column(19)
MsgBox " " & Trim(FAMILY) & " ! ", _
vbOKOnly + vbExclamation, " "
Else
SuperVisor = False '
MsgBox " " & Trim(FAMILY) & " ! ", _
vbOKOnly + vbExclamation, " "
Application.Quit acQuitSaveAll '
End If
End If
DoCmd.Close

'

StartMainMenu

'

End Sub

,
, ComboBox
Null.
(Exit Sub). , , . . .
10 , ( Dropdown).
- ,
, .
tblUser (,
MS Access ) . , . "" ODBC , . .
, .

8.

257

, , . , , , ,
Access01Access14 tblUser.
(DoCmd.Close) (StartMainMenu).
ModuleMain.
8.8. Click
Private Sub 1_Click()
' -
'
StopMenu ' ModuleSlave
End Sub

8.4.
(),
, .
. PassWord.
( | ).
PassWord . 8.3. . 8.4 .

II.

258

. 8.3. PassWord

8.4. PassWord.

SELECT tblUser.LastName,
tblUser.FirstName,
tblUser.SecondName, tblUser.Post,
tblUser.PassWord, tblUser.Date_up,
User.Time_up FROM [tblUser] WHERE
(((tblUser.LastName)=GetValueSQL()));

8.4 ()

- SharePoint

8.

10

11

12

13

14

259

PassWord ,
,
(. 8.4). :
1. C

,
. .

2. . tblUser.
3. : LastName, FirstName,
SecondName, Post, PassWord, Date_Up

Time_Up.

.
4. LastName ()

GetValueSQL().
5. .

II.

260

. 8.4.
PassWord

MS Access 2007
. , ,
, .

LastName FAMILY ( )
GetValueSQL(). ModuleSlave,
8.9.
"" . Visual Basic for Applications

. 8.10. , .
.
8.9.
Public Function GetValueSQL()
' FAMILY
'
' SQL-

8.

261

' MS Access
GetValueSQL = FAMILY
End Function

. 8.5.

. 8.5. PassWord

, Click PassWord ( 8.10).


8.10.
Private Sub 2_Click()
'
Dim OldPassword As String

'

Dim NewPasswordOne As String

'

Dim NewPsswordTwo As String

'

Dim TextSQL As String

' SQL-

' : SqlUpdateErr
On Error GoTo SqlUpdateErr
If IsNull([Forms]![PassWord]![PassWord]) Then
'

II.

262

MsgBox " .", _


vbOKOnly + vbExclamation, ""
'
[Forms]![PassWord]![OldPassword].SetFocus
'
Exit Sub
End If
OldPassword = [Forms]![PassWord]![OldPassword]
'
OldPassword = Trim(OldPassword)
'
OldPassword = CrKod(OldPassword)
If OldPassword <> Trim([Forms]![PassWord]![CrPassWord]) Then
'
MsgBox " .", _
vbOKOnly + vbExclamation, ""
'
[Forms]![PassWord]![OldPassword].SetFocus
'
Exit Sub
End If
If IsNull([Forms]![PassWord]![NewPassword1]) Then
'
MsgBox " .", _
vbOKOnly + vbExclamation, ""
'
[Forms]![PassWord]![NewPassword1].SetFocus
'
Exit Sub
End If
If IsNull([Forms]![PassWord]![NewPassword2]) Then
'
MsgBox " .", _
vbOKOnly + vbExclamation, ""
'
[Forms]![PassWord]![NewPassword2].SetFocus
'
Exit Sub
End If

8.
'
NewPasswordOne = Trim([Forms]![PassWord]![NewPassword1])
NewPsswordTwo = Trim([Forms]![PassWord]![NewPassword2])
If NewPasswordOne <> NewPsswordTwo Then
MsgBox " .", _
vbOKOnly + vbExclamation, ""
'
[Forms]![PassWord]![NewPassword2].SetFocus
'
Exit Sub
End If
If Len(NewPasswordOne) <= 4 Then
MsgBox " - 5 .", _
vbOKOnly + vbExclamation, ""
'
[Forms]![PassWord]![NewPassword1].SetFocus
'
Exit Sub
End If
'
NewPasswordOne = CrKod(NewPasswordOne)
If CrKod(NewPasswordOne) = _
Trim([Forms]![PassWord]![CrPassWord]) Then
MsgBox " .", _
vbOKOnly + vbExclamation, ""
'
[Forms]![PassWord]![NewPassword1].SetFocus
'
Exit Sub
End If
' SQL-
TextSQL = "UPDATE tblUser " & _
"SET tblUser.PassWord = '" & NewPasswordOne & "'," & _
"tblUser.Date_Up=Date(),tblUser.Time_Up=Time()" & _
"WHERE tblUser.LastName = '" & FAMILY & "' "
' Debug.Print TextSQL
'
DoCmd.RunSQL TextSQL

263

II.

264
'
DoCmd.Close
Exit Sub
SqlUpdateErr:
If Err.Number = 2501 Then

MsgBox " .", _


vbOKOnly + vbExclamation, ""
Else
'
MsgBox " :" & vbCrLf & _
Err.Description & vbCrLf & " " & _
Err.Number, vbCritical
Resume Next
End If
End Sub

VBA:
IsNull() True, (
Null);

Len() ;
Trim() .

:
1. ?
2. ?
3. ?
4. ?
5. ?
6. ?
7. ?

, .
.

8.

265

,
, ?

,
?


( CrKod()) SQL-
tblUser. : ,
.
- , . FAMILY.
SQL- VBA.
RunSQL. (. 8.6).

. 8.6.

, Microsoft Visual Basic


2501 (. 8.7).
. , : End
Debug .
2501

II.

266

, . , , , :
On Error GoTo SqlUpdateErr

SqlUpdateErr .

, .
, . . : Exit Sub.

. 8.7.

. 8.8.

Microsoft Visual Basic (. 8.7)


(. 8.8). ""

8.

267

( ), , -, .
2501
, .
(. . 8.8), ,
RunSQL (. 8.9).

. 8.9. 2501

,
, Raise Err,
, Number.
Description .
Description .

.
"Printer error" " ".
Err.Raise Number:=482, Description:=" "

,
"" .
MS Office Access 2007
. :
1. MS Access Office.

. .
2. Access.
3. Access

(. 8.10).
4. -

II.

268

. 8.10. MS Access 2007

PassWord ( ) : ,
, , .
, . 8.5.
8.5.

(Enable)

(Lock)

(Visible)

. .
"" ,
, .
.

8.

269

8.5.

Employee
.
, ,
.
. . , , .
. .
. 8.6 Employee.
8.6. Employee

-
SharePoint

10

11

12

13

II.

270

().
.
. MS Access 2007 . .
.
. . . 8.7
.

8.7. Employee

(

PageFrame)


(Page1)

ListBox

CommandAdd

VBA

txtCountWorker


(Page2)
-

txtLastName

LastName

txtFirstName

FirstName

txtSecondName

SecondName

txtPost

Post

txtFile

File

txtPassWord

PassWord

OptionGroup

Range

PictureUser

DCount()

8.

271

8.7 ()


ChkAccess01
...

...

Access01

chkAccess14

...
Access14

txtInspector

Inspector

txtDate_up

Date_up

txtTime_up

Time_up

CommadeSave

VBA

CommandDel

VBA

CommandDelPassword

VBA

CommandExit

VBA


ListBox. ,

, . 8.8.
8.8. ListBox.

ListBox

SELECT tblUser.LastName,
tblUser.FirstName,
tblUser.SecondName,
tblUser.Post FROM tblUser;

II.

272

2,5;2,3;3;4

ListBox .
tblUser,
. txtCounWorker, tblUser ( ),
:
=DCount("*";"tblUser")

Dcount() .
. 8.11.

. 8.11. Employee

8.11 . .
Public ModuleMain:
Public SelectLastName As String

'

Public SelectFirstName As String

'

Public SelectSecondName As String

'

8.
Public Indicator As Integer

273

'

.
8.11. Employee
Private Sub Form_Load()
'
Indicator = 0

'

' Indicator=1

' Indicator=2

' Indicator=3

'
SelectLastName = ""
'
SelectFirstName = ""
'
SelectSecondName = ""
End Sub

. 8.12 Employee .

II.

274

. 8.12. Employee

,
.
Click 8.12.
8.12. ListBox
Private Sub ListBox_Click()
Dim TextSQL As String '
Indicator = 2 '
' " " Form_BeforeUpdate
' ,
'
' TextSQL = "Select * from tblUser where LastName = '" & _
' ListBox.Value & "'"
'
SelectLastName = [ListBox].Column(0)
'
SelectFirstName = [ListBox].Column(1)
'
SelectSecondName = [ListBox].Column(2)
TextSQL = "Select * from tblUser where LastName = '" & _
SelectLastName & "'" & _
" AND FirstName = '" & SelectFirstName & "'" & _
" AND SecondName = '" & SelectSecondName & "'"
Me.RecordSource = TextSQL
Page2.Visible = True
Page2.SetFocus
' ,
'
' txtLastName.Locked = True
' txtFirstName.Locked = True
' txtSecondName.Locked = True
End Sub


tblUser, .
,

8.

275

, Value ListBox. 1 ListBox. .



tblUser, :
LastName + FirstName + SecondName

SelectLastName,
SelectFirstName SelectSecondName. ? Column ListBox. ( ), ( )
( ):
SelectLastName = [ListBox].Column(0)
SelectFirstName = [ListBox].Column(1)
SelectSecondName = [ListBox].Column(2)

Employee . 8.13.

. 8.13. Employee

II.

276

, , , . . I. ,
.
. 8.9.
8.9. Employee

PassWord

OptionGroup

txtInspector

txtDate_up

txtTime_up

PictureUser

=CurrentPath() & "\PHOTO\"


& [txtFile].Value & ".jpg"

.
tblUser (Form_BeforeUpdate)
. txtDate_up
txtTime_up, .
(OptionGroup) 1. ,
, " ". . 0 . . 8.14
.
Employee ,
. 8.13
OptionGroup. . ,
() , chkAccess01
chkAccess14, . -

8.

277

(
) .

. 8.14. Employee

8.13. OptionGroup
Private Sub OptionGroup_AfterUpdate()
'
chkAccess01.Value = True

'

chkAccess02.Value = True

'

chkAccess03.Value = False

'

chkAccess04.Value = False

'

chkAccess05.Value = True

'

chkAccess06.Value = False

'

chkAccess07.Value = False

'

chkAccess08.Value = False

'

chkAccess09.Value = False

'

chkAccess10.Value = False

'

II.

278
chkAccess11.Value = False

'

chkAccess12.Value = False

'

chkAccess13.Value = False

'

chkAccess14.Value = False

'

'
Select Case OptionGroup.Value
Case 1

'

chkAccess06.Value = True '


chkAccess07.Value = True '
chkAccess08.Value = True '
chkAccess10.Value = True '
chkAccess11.Value = True '
chkAccess13.Value = True '
Case 2

'

chkAccess06.Value = True '


chkAccess08.Value = True '
chkAccess09.Value = True '
Case 3

'

chkAccess06.Value = True '


chkAccess08.Value = True '
chkAccess10.Value = True '
Case 4

'

chkAccess03.Value = True '


chkAccess04.Value = True '
chkAccess14.Value = True '
End Select
End Sub

8.14. CommandSave
Private Sub CommandSave_Click()
'
Dim NewPasswordOne As String '
NewPasswordOne = "00000"

'

If IsNull(txtLastName.Value) Then
'
MsgBox " .", _
vbOKOnly + vbExclamation, ""

8.
'
txtLastName.SetFocus
'
Exit Sub
End If
If IsNull(txtFirstName.Value) Then
'
MsgBox " .", _
vbOKOnly + vbExclamation, ""
'
txtFirstName.SetFocus
'
Exit Sub
End If
If IsNull(txtSecondName.Value) Then
'
MsgBox " .", _
vbOKOnly + vbExclamation, ""
'
txtSecondName.SetFocus
'
Exit Sub
End If
If IsNull(txtPost.Value) Then
'
MsgBox " .", _
vbOKOnly + vbExclamation, ""
'
txtPost.SetFocus
'
Exit Sub
End If
If IsNull(txtFile.Value) Then
'
MsgBox " .", _
vbOKOnly + vbExclamation, ""
'
'

279

II.

280
txtFile.Value = "NoFoto"
txtFile.SetFocus
'
Exit Sub
End If

If OptionGroup.Value = 0 Then
'
MsgBox " .", _
vbOKOnly + vbExclamation, ""
'
OptionGroup.SetFocus
'
Exit Sub
End If
txtInspector.Value = FAMILY
txtDate_up = Date
txtTime_up = Time()
If Page2.Caption = " " Then
' -
NewPasswordOne = CrKod(NewPasswordOne)
txtPassWord.Value = NewPasswordOne
End If
DoCmd.Close

'

End Sub

( 8.15) . ,
, (, ), .
txtLastName, txtFirstName txtSecondName. SelectLastName, SelectFirstName
SelectSecondName. , .
8.15. CommandDel
Private Sub CommandDel_Click()
'

8.

281

Dim TextSQL As String '


' : SqlUpdateErr
On Error GoTo SqlUpdateErr
TextSQL = "DELETE from tblUser where LastName = '" & _
SelectLastName & "'" & _
" AND FirstName = '" & SelectFirstName & "'" & _
" AND SecondName = '" & SelectSecondName & "'"
'
DoCmd.RunSQL TextSQL
' " "
' Form_BeforeUpdate
Indicator = 3
DoCmd.Close

'

SqlUpdateErr:
If Err.Number = 2501 Then
MsgBox " .", _
vbOKOnly + vbExclamation, ""
End If
End Sub

.
TextSQL.
SQL- VBA. RunSQL. 2501. ,
, .
Indicator 3. ( ) .
, , ( 8.16). , .
. ( ), .

II.

282

8.16. CommandDelPassWord
Private Sub CommandDelPassword_Click()
Dim TextSQL As String

'

Dim NewPasswordOne As String '


NewPasswordOne = "00000"

'

'
NewPasswordOne = CrKod(NewPasswordOne)
' SQL-
' SelectLastName, SelectFirstName, SelectSecondName ' .
' DblClick ListBox
If MsgBox(" ? ", _
vbInformation + vbYesNo, "") = vbYes Then
TextSQL = "UPDATE tblUser" & _
" SET tblUser.PassWord = '" & NewPasswordOne & "' " & _
" WHERE LastName = '" & SelectLastName & "' " & _
" AND FirstName = '" & SelectFirstName & "'" & _
" AND SecondName = '" & SelectSecondName & "'"
' Debug.Print TextSQL
DoCmd.RunSQL TextSQL
Indicator = 3 '
' < >

' Form_BeforeUpdate
DoCmd.Close

'

End If
End Sub

, (5 ) . , - tblUser.
, . . Login,
(. 8.15). tblUser
. .
8.17 . Employee. , -

8.

283

.
( ). , . . . TextSQL.
"" :
Me.RecordSource = TextSQL

. 8.15. ,

8.17. CommandAdd
Private Sub CommandAdd_Click()
'
Dim TextSQL As String '
Indicator = 1

'

' < >


' <Form_BeforeUpdate>
' 1
' ,
'
'
' TextSQL = "SELECT * from tblUser WHERE LastName = ''"
' - TextSQL
' Me.RecordSource = TextSQL
' 2. Access
'
DoCmd.GoToRecord acDataForm, "Employee", acNewRec

II.

284

'
Page2.Visible = True
'
Page2.Caption = " "
'
CommandDelPassword.Enabled = False
'
CommandDel.Enabled = False
'
txtLastName.SetFocus
' ( )
Page1.Visible = False
End Sub

" " . ,
. 8.16. .

. 8.16.

8.

285

Employee "" :
TextSQL = "SELECT * from tblUser WHERE LastName = ''"
Me.RecordSource = TextSQL

VBA:
DoCmd.GoToRecord acDataForm, "Employee", acNewRec

, . VBA "",
, Employee:
DoCmd.GoToRecord ,,acNewRec

:
DoCmd.GoToRecord _, _, ,

:
_ , . 8.10;
_ , ;
, . 8.11;
( acGoTo).
8.10. ,

acActiveDataObject

,
(
)

acDataForm

acDataFunction

10


( adp-)

acDataQuery

acDataReport

acDataServerView

(
adp-)

acDataStoredProcedure

(
adp-)

II.

286
acDataTable

8.11. , ,

acFirst

acGoTo

acLast

acNewRec

acNext

acPrevious

8.18 CommandExit.
.
(Indicator=3) .
8.18.
Private Sub CommandExit_Click()
'
'
' " "
' Form_BeforeUpdate
Indicator = 3
DoCmd.Close

'

End Sub

8.19
. , Indicator, -

8.

287


.
8.19. Employee
Private Sub Form_BeforeUpdate(Cancel As Integer)
'
Select Case Indicator
Case 1 '
If MsgBox(" ? ", _
vbInformation + vbYesNo, "") = vbNo Then
'
DoCmd.RunCommand acCmdUndo
End If
Case 2 '
If MsgBox(" ? ", _
vbInformation + vbYesNo, "") = vbNo Then
'
DoCmd.RunCommand acCmdUndo
End If
Case Else
'
'
DoCmd.RunCommand acCmdUndo
End Select
End Sub



. . . ,
. , .

9.1.

MS Office Access . , , MS
Office Access, .
, MS Office Access.
.
, , . , , .
,
. , . ,
, .

288

II.

MS Office Access
: ,
"" .
"",
. , ,
. .
,
, , ,
, SELECT, , . 90%
,
, . : ,
: "" "" . MS Office
Access .
: , .
. , -

. ? "" ,
?
. , -

, ,
.
, , .
. -

, . , ,
?
, . . .

9.

289


:
;
;
.

. , ,
. ,
, ,
account .
.
.
, .
. ,
flat
. , , .
, . , .
.
.
, ,
. , ,
. / , MS Office Access
, .
.
MS Office Access, ,
. , , . , ,
. , , .
MS Office Access ,

, .

II.

290

9.2. MS Office Access


MS Office Access . .
. . -

, .
, . , , , .
. .

.
, , .
MS Office Access 2007:
1. Microsoft Access 2007 Office.

Office.
2. Access.

.
3.

(. 9.1).
4. OK.

.
:

. ;

.
;

, . , ;

9.

291

. 9.1.


. , .
OLE/DDE () -

OLE DDE .
0 300. 30.
() , Microsoft Access

. 0 32 766. 60.
.

, , Microsoft Access
. 0 10. 2.

II.

292

ODBC () ,

, ODBC-.
. 0 32 766. 1500. .
() ,

Microsoft Access , .
0 1000. 250.


, Recordset ,
SQL. .
.
. : , .

9.3.
.
.
, . : , .
.
.
.

,
, - . ,
.
MS Office Access
, (. 9.2).

9.

293

. 9.2.

, , . , ,
. , . ,
,
. ,
, : ,
, , .
,
I. Building, .
: , .
, . 9.1, .
9.1. Building

100000

294

II.

, -
, ,
(. 9.3). . .
, , .
- ,
. .
.
, - .
: " ?". ,
! .
. 9.1.
100 .

. 9.3.

9.

295

9.1.
Private Sub Form_Timer()
' ,
' " "
If Not CurrentProject.AllForms("Flats").IsLoaded Then
' ,
'
DoCmd.Close
End If
End Sub

.
. , ? Building , . . Flats Building. : Flats ,
, "" .
. ,
Building . - 100 .
? Building ! ,
, , .
9.2 .
9.2.
Private Sub Form_Activate()
'
Me.TimerInterval = 100000
End Sub

100 .
. , .
100 , ? 9.3 ,
. .

II.

296

9.3.
Private Sub Form_Current()
'
'
Me.TimerInterval = 100000
End Sub

, ,
. 60
(. 9.1, ()) , , , , , .

,
.

. - , .
MS Access .
, .
MS Access , ,
- ,
. ,
.
,
, .
. ? ,
, .

9.

297

.
(. . 9.2). .
Microsoft Word (. 9.2). .
9.2. ,
ComboStreet

txtHOUSE

ComboDistrict

txtLAND

txtYEAR

10

31000

1996

. 9.3.
.

9.4.

1995 Windows Microsoft Tastrade, (Page
Frame). ,
. , , , ! , , . MS
Office Access 2007, ,
, . , - Page Frame MS Office Access .
. PageBuilding.
MS Office Access . .
, , Access
, ,
"" . -

298

II.

, . . 9.4
PageBuilding .
:
, , .
MS Access, . , , ,
. .
. .
. .
. , . . 9.5 , , . 334.
(. 9.6).

. 9.4.

9.

. 9.5.

. 9.6.

299

300

II.

. .
.
( , )
. ,
( ) ,
. " " (. 9.7).

. 9.7.

9.4.1.


.
-

9.

301

. . :
1. .

.
2. . .


,
.
3. . . -

Page1, Page2 Page3 .

. 9.8.

II.

302

4. .

, .
5. -

.
6. PageFrame.

. 9.8 ,
. 9.3 PageBuilding.
9.3. PageBuilding

ComboBoxSeekStreet

SELECT tblStreet.STREET,
tblStreet.NAME,
tblStreet.SIGN,
tblStreet.FIRST FROM
tblStreet ORDER BY
tblStreet.[NAME],
tblStreet.[SIGN];

txtSignSeek

=[ComboBoxSeekStreet].
[Column](2)

txtSeekHouse

ComboBoxSeekDistrict

OptionSort

SELECT tblDistrict.DISTRICT, tblDistrict.AREA FROM tblDistrict ORDER BY


tblDistrict.[AREA];

: 1

PicStreet

CommandKill

VBA ( 9.5)

CommandSeek

VBA ( 9.6)

CommandExit

VBA (. -)

9.4 PageBuilding.
MS Access, VBA (. 9.9).

9.

303

"Form_"
.

. 9.9. Form_PageBuilding

. .
1. MS Office Access 2007 -

.
2. Visual Basic for Applications.
3. VBA .

View Project Explorer.


4. Form_PageBuilding

.
9.4. Form_PageBuilding
Option Explicit
Option Compare Database

304

II.

'
Public SelectStreet As Integer

'

Public SelectHouse As Integer

'

'
Dim SelectSeekStreet As Integer

'

Dim SelectSeekHouse As Integer

'

Dim SelectSeekDistrict As Integer '


Dim SelectSort As Integer

'

Dim SQLText As String

'

Dim Indicator As Integer

'

, . , .
: , . .
( ), Public. SelectStreet SelectHouse. 9.5 ,
.
9.5.
Private Sub CommandKill_Click()
'
'
'
ComboBoxSeekStreet.Value = Null
'
txtSeekHouse.Value = Null
'
ComboBoxSeekDistrict.Value = Null
' -
OptionSort.Value = 1
End Sub

9.6 (RowSource)
ListBox . , . .
WHERE, FROM-INNER-

9.
JOIN-ON.

305

, .
.
: , , , . . . , ,
(, ).
AND. : ORDER BY.
"".
9.6.
Private Sub CommandSeek_Click()
'
Dim CountBuilding As Integer
' ,
If IsNull(ComboBoxSeekStreet.Value) Then
'
SelectSeekStreet = 0
Else
'
SelectSeekStreet = ComboBoxSeekStreet.Value
End If
If IsNull(txtSeekHouse.Value) Then
'
SelectSeekHouse = 0
Else
'
'
SelectSeekHouse = Val(txtSeekHouse.Value)
End If
If IsNull(ComboBoxSeekDistrict.Value) Then
'
SelectSeekDistrict = 0
Else
'
SelectSeekDistrict = ComboBoxSeekDistrict.Value
End If
'

II.

306

SelectSort = OptionSort.Value
'
'
SQLText = "SELECT tblBuilding.Street, " & _
"tblStreet.Name AS , " & _
"tblStreet.Sign AS , " & _
"tblBuilding.House AS , tblDistrict.AREA AS , " & _
"tblBuilding.Land AS , tblBuilding.Year AS " & _
"FROM tblStreet, tblBuilding, tblDistrict " & _
"WHERE

tblStreet.Street = tblBuilding.Street " & _

"AND tblDistrict.District = tblBuilding.District "


'
If SelectSeekStreet <> 0 Or SelectSeekHouse <> 0 Or _
SelectSeekDistrict <> 0 Then
If SelectSeekStreet <> 0 Then
'
SQLText = SQLText & " AND tblBuilding.Street =" & _
SelectSeekStreet
End If
If SelectSeekHouse <> 0 Then
'
SQLText = SQLText & " AND tblBuilding.House =" & _
SelectSeekHouse
End If
If SelectSeekDistrict <> 0 Then
'
SQLText = SQLText & " AND tblBuilding.District =" & _
SelectSeekDistrict
End If
End If
' -
Select Case SelectSort
Case 1

'

SQLText = SQLText & " ORDER BY Name, Sign, House"


Case 2

'

9.
SQLText = SQLText & " ORDER BY tblDistrict.Area"
Case 3

'

SQLText = SQLText & " ORDER BY tblBuilding.Land"


Case 4

'

SQLText = SQLText & " ORDER BY tblBuilding.Year"


End Select
'
' ( )
ListBox.RowSourceType = "Table/Query"
'
ListBox.RowSource = SQLText
' ,
CountBuilding = CountQuery(SQLText)
If CountBuilding = 0 Then
'
MsgBox ", " & _
", . , " & _
" .", _
vbOKOnly + vbExclamation, ""
'
Exit Sub
End If
'
CountRecords.Caption = _
" , : " & _
Str(CountBuilding)
' " "
ListBox.Selected(1) = True
'
Page2.Visible = True
'
Page2.SetFocus
End Sub

307

II.

308

, , MS Access
,
SQL. . , . . . 1.1.
distict ( "r"
"district"). , SQL district, MS Access
,
: " !". , , , .

,
(. 9.10), .

. 9.10.

, .
, .

9.4.2. VBA. Microsoft ADO


, , CountQuery(). : SQLText
. 9.7.
ActiveX Data Objects (ADO).

9.
9.7.
Public Function CountQuery(SQLText) As Integer
'
' SQLText -
Dim CountSelectSQL As Integer

'

'
Dim Connect As ADODB.Connection
' Connect - ,
' ADO
Dim rsCount As ADODB.Recordset
' rsCount - ,
'
'Set Connect = CurrentProject.Connection
'
Set Connect = New ADODB.Connection
' MS Access 2007 ( accdb)
With Connect
.ConnectionString = _
"Provider=Microsoft.ACE.OLEDB.12.0;" & _
"Data Source=" & CurrentPath() & "\Real Estate.accdb"
.Open
End With
Set rsCount = New ADODB.Recordset

'

With rsCount
' rsCount (Recordset)
' : SQL-
.Source = SQLText
'
.ActiveConnection = Connect
.CursorType = adOpenKeyset

'

' RS
'
.Open
End With

309

II.

310

CountSelectSQL = rsCount.RecordCount
' RecordCount - rsCount
'
'
Set rsCount = Nothing
Set Connect = Nothing
'
' CountQuery -
CountQuery = CountSelectSQL
End Function

ADO . , .
, .
ADO (. 9.11).
ADO :
;
,

;
, .

"" ? , !
.
1. VBA.

. 9.11. ADO

9.

311

2. View.
3. Object Browser. Object

Browser.
4. ,

, : Access, ADODB, Office . .


5. ADODB (. 9.12). -

, .

. 9.12. Connection ADODB


ConnectionString

, (. 9.7)
. Connect Connection ADODB. Microsoft.ACE.OLEDB.12.0
MS Access 2007, Real Estate.
Open.
:
Dim Connect As ADODB.Connection
Set Connect = New ADODB.Connection
With Connect
.ConnectionString = _
"Provider=Microsoft.ACE.OLEDB.12.0;" & _

II.

312

"Data Source=" & CurrentPath() & "\Real Estate.accdb"


.Open
End With

. 9.13. Recordset ADODB


ActiveConnection CursorType,

rsCount Recordset ADODB (. 9.13).


SQL-. SQLText. , Connect. CursorType adOpenKeyset.
Dim rsCount As ADODB.Recordset
Set rsCount = New ADODB.Recordset
With rsCount
.Source = SQLText

9.

313

.ActiveConnection = Connect
.CursorType = adOpenKeyset
.Open
End With

9.4.3.
ListBox.
, .
.
, ,
( )
, (, ) .
, ListBox, 0.
9.8 ,
. .
9.8. ListBox
Private Sub ListBox_DblClick(Cancel As Integer)
Dim TxtSQL As String '
Indicator = 2

'

' " "


' Form_BeforeUpdate
'
SelectStreet = [ListBox].Column(0)
'
SelectHouse = [ListBox].Column(3)
'
TxtSQL = "SELECT * FROM tblBuilding WHERE Street = " & _
SelectStreet & " AND House = " & SelectHouse
' -
Me.RecordSource = TxtSQL

314

II.

'
Page3.Visible = True
Page3.SetFocus
End Sub

(SelectStreet) (SelectHouse). . (
) , -
, . ( ) .

ADO. , ,
c , ,
. ListBox.
ListCount ( ). txtCoundBld
. :
=ListBox.Count -1

ListBox , :
=ListBox.Count

. !
9.9 VBA,
. .
9.9.
Private Sub CommandAdd_Click()
'
Dim TextSQL As String '
Indicator = 1

'

' " "


' Form_BeforeUpdate
' ,
'
'
TextSQL = "SELECT * from tblBuilding WHERE Street = -1"

9.

315

' - TextSQL
Me.RecordSource = TextSQL
' ()
Page1.Visible = False
' ( )
Page2.Visible = False
'
Page3.Visible = True
'
Page3.Caption = " "
'
CommandFlats.Enabled = False
'
CommandDel.Enabled = False
' ()
ComboStreet.SetFocus
End Sub

, .
. ,
. .
building, . .
street. .
STREET >=0. , building .

9.4.4.
PageBuilding
.
Indicator. .
, . . 9.4
.
. 9.14 .

II.

316

9.4. PageBuilding

ComboStreet

SELECT
[tblStreet].[STREET],
[tblStreet].[NAME],
[tblStreet].[SIGN] FROM
tblStreet;

=1

txtSign

=[ComboStreet].[Column](2)

txtHouse

HOUSE

ComboDistrict

SELECT [tblDistrict].DISTRICT, [tblDistrict].AREA FROM tblDistrict;

txtLAND

LAND

txtYear

YEAR

txtFLATS

FLATS

ComboMaterial

SELECT
[tblWall].[MATERIAL],
[tblWall].[WALL] FROM
tblWall;

txtComment

COMMENT

txtWear

WEAR

txtCost

COST

txtLine

LINE

9.

317

9.4 ()

txtSquare

SQUARE

OptionGroup

KIND

txtInspector

INSPECTOR

DATE_UP

TIME_UP

txtDate_up

txtTime_up

txtPicture

PICTURE

Picture

=CurrentPath() &
"\Building\" & [txtPicture].[Value]

, NoFoto.jpg

chkELEVATOR

ELEVATOR

ChangePhoto

VBA ( 9.10)

CommandSave

VBA ( 9.11)

CommandDel

VBA ( 9.12)

CommandFlats

VBA ( 9.13)

CommandExit

VBA ( 9.14)


, . "" -

318

II.

txtPicture, .
, Picture (NoFoto.jpg).
Building.
,
OLE.
,
. ( 9.10).
ADO. Microsoft Office 12.0 Object
Library ,
. FileDialog,
(. 9.15).

. 9.14.

9.
9.10.
Private Sub ChangePhoto_Click()
'
' txtPicture
' VBA - Tools - Reference ' Microsoft Office 12.0 Object Library
' fDialog -
'
' MS Office 2007
Dim fDialog As Office.FileDialog
'
Dim varFile As Variant

' Varint -

'
Set fDialog = Application.FileDialog(msoFileDialogFilePicker)
'
With fDialog
'
.AllowMultiSelect = False
'
.Title = " "
' ,
.Filters.Clear
'
.Filters.Add "All Files", "*.*"
If .Show = True Then
'
For Each varFile In .SelectedItems
'
' - Dir()
txtPicture.Value = Dir(varFile)
Next
Else
MsgBox " " & _

319

II.

320

" .", _
vbOKOnly + vbExclamation, ""
End If
End With
End Sub

. 9.15. FileDialog Office

fDialog,
FileDialog. ,
: " ". . , "" , .
, (*.* ). , , txtPicture : Dir(varFile).
9.11
CommandSave. . ,
, , -

9.

321

. , MS Access
, ,
(. 9.16).
9.11.
Private Sub CommandSave_Click()
'
If IsNull(ComboStreet.Value) Then
'
MsgBox " .", _
vbOKOnly + vbExclamation, ""
'
ComboStreet.SetFocus
'
Exit Sub
End If
If IsNull(txtHOUSE.Value) Then
'
MsgBox " .", _
vbOKOnly + vbExclamation, ""
'
txtHOUSE.SetFocus
Exit Sub
End If
If IsNull(ComboDistrict.Value) Then
MsgBox " .", _
vbOKOnly + vbExclamation, ""
ComboDistrict.SetFocus
Exit Sub
End If
If IsNull(txtLAND.Value) Then
MsgBox " .", _
vbOKOnly + vbExclamation, ""
txtLAND.SetFocus
Exit Sub
End If
If IsNull(txtYEAR.Value) Then

II.

322

MsgBox " .", _


vbOKOnly + vbExclamation, ""
txtYEAR.SetFocus
Exit Sub
End If
If Me.Dirty Then
' Dirty = True,
'
txtINSPECTOR.Value = FAMILY '
txtDATE_UP = Date

'

txtTIME_UP = Time()

'

'
DoCmd.RunCommand acCmdSaveRecord
' " "
' Sub Form_BeforeUpdate
Page2.SetFocus
End If
End Sub

. 9.16.

, , . : , Null. MS Access 2007:

9.

323

If IsNull(ComboStreet.Value) Then
MsgBox " .", _
vbOKOnly + vbExclamation, ""
ComboStreet.SetFocus
Exit Sub
End If

, .
Dirty True : txtInspector, txtDate_up
txtTime_up. Value .
, :
DoCmd.RunCommand acCmdSaveRecord
Page2.SetFocus
9.12.
Private Sub CommandDel_Click()
'
Dim TextSQL As String '
' : SqlUpdateErr
On Error GoTo SqlUpdateErr
TextSQL = "DELETE from tblBuilding WHERE Street = " & _
SelectStreet & _
" AND House = " & SelectHouse
'
DoCmd.RunSQL TextSQL
' " "
' Form_BeforeUpdate
Indicator = 3
DoCmd.Close

'

SqlUpdateErr:
If Err.Number = 2501 Then
MsgBox " .", _
vbOKOnly + vbExclamation, ""
End If
End Sub

II.

324

9.13.
Private Sub CommandFlats_Click()
'
On Error GoTo Err_CommandFlats_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "Flats"
DoCmd.OpenForm stDocName, , , stLinkCriteria
Exit_CommandFlats_Click:
Exit Sub
Err_CommandFlats_Click:
MsgBox Err.Description
Resume Exit_CommandFlats_Click
End Sub

9.14.
Private Sub CommandExit_Click()
'
DoCmd.Close

'

End Sub

Page3, PageFrame. . PageFrame . MS Access ,


.
9.15 9.16 : .
9.15. PageBuilding
Private Sub Form_BeforeUpdate(Cancel As Integer)
'
Select Case Indicator
Case 1 '
If MsgBox(" ? ", _

9.
vbInformation + vbYesNo, "") = vbNo Then
DoCmd.RunCommand acCmdUndo
End If
' ()
Page1.Visible = True
' ( )
Page2.Visible = True
Page2.SetFocus
'
Page3.Visible = False
'
Page3.Caption = ""
'
CommandFlats.Enabled = True
'
CommandDel.Enabled = True
Case 2 '
If MsgBox(" ? ", _
vbInformation + vbYesNo, "") = vbNo Then
DoCmd.RunCommand acCmdUndo
End If
Case Else
'
DoCmd.RunCommand acCmdUndo
End Select
End Sub

9.16. PageBuilding
Private Sub Form_AfterUpdate()
'
'
ListBox.Requery
End Sub

325

10


, MS Access 2007,
, MS Excel MS Word .
Access- MS Office.
,
, ,
COM (Component Object Model, ). .
MS Excel, Word , , , , , .
, Delphi, Visual FoxPro
. Access- .
MS Office VBA, (. 5).
.

10.1.
Microsoft Excel 2007
MS Excel . , , ,
VBA,
, -

10.

327

. ,
, "" , .

10.1.1.
. MS Excel 2007.
.
, .
. .
. OK. . ,
( 10.1).
.

. 10.1.

II.

328

,
( 10.1). <Alt>+<F8>, .
10.1. ,
Sub 1()
Range("A1").Select
ActiveCell.FormulaR1C1 = ""
Range("B1").Select
ActiveCell.FormulaR1C1 = ""
Range("C1").Select
ActiveCell.FormulaR1C1 = ""
Range("A1:C1").Select
With Selection.Font
.Name = "Times New Roman"
.Size = 12
.Shadow = False
.Underline = xlUnderlineStyleNone
.ThemeColor = xlThemeColorLight1
.ThemeFont = xlThemeFontNone
End With
End Sub

MS Office . :
xlUnderlineStyleNone;
xlThemeColorLight1;
xlThemeFontNone.

MS Office VBA-,

.
.

10.

329

10.1.2.
Microsoft Excel 12.0 Object Library
VBA MS Excel (
"xl"), .
:
1. MS Access 2007. -

.
2. Visual Basic, ,

.
3. VBA Tools. .
4. References. -

(. 10.2).
5. Microsoft Excel 12.0 Object Library.
6. OK.

. 10.2. Microsoft Excel 12.0 Object Library

II.

330

accdb- adp-
.

10.1.3. MS Excel
MS Access
, MS Excel , MS Access, . ,
VBA ( 10.2).
10.2.
Public Sub 1()
Dim oExcel As Object
...
With oExcel
.Range("A1").Select
.ActiveCell.FormulaR1C1 = ""
.Range("B1").Select
.ActiveCell.FormulaR1C1 = ""
.Range("C1").Select
.ActiveCell.FormulaR1C1 = ""
.Range("A1:C1").Select
With .Selection.Font
.NAME = "Times New Roman"
.Size = 12
.Shadow = False
.Underline = xlUnderlineStyleNone
.ThemeColor = xlThemeColorLight1
.ThemeFont = xlThemeFontNone
End With
End With
End Sub

. .
oExcel. ,

10.

331

. With, . , .

10.1.4. Application
oExcel CreateObject,
MS Excel ( 10.3). MS Excel
, ,
. ,
Windows
- , . Excel :
oExcel.Application.Visible = False

, . , ""
VBA, .
10.3.
Public Sub ReportExcel()
'
Set oExcel = CreateObject("Excel.Application")
' Microsoft Excel
oExcel.Application.Visible = True
' MS Excel
oExcel.Application.WindowState = xlMaximized
'
oExcel.WorkBooks.Add
'
'
oExcel.DisplayAlerts = False
' 75%
oExcel.ActiveWindow.Zoom = 75
' Excel
oExcel.Caption = " "

II.

332

' Excel
oExcel.Cells.Font.NAME = "Arial"
oExcel.Cells.Font.Size = 7
End Sub

10.1.5. , Real Estate


, Flats,
. , MS Access (. 10.3).

. 10.3. , MS Excel 2007

10.

333

,
, ,
Excel. , 10.4.
. ModuleSlave Real Estate.
10.4. , MS Excel 2007
Public Sub AccountExcel()
' MS Excel
'
' SelectAddressStreet

' SelectAddressHouse

' SelectAddressFlat

' tblExcel
' tblExcel Real Estate.
' ,
' RSset
Dim RSset As ADODB.Recordset

'

Set RSset = New ADODB.Recordset


' . - Variant
Dim I, NachAll, YmAll, DonaAll, YpAll, ReturnAll, NachPeniAll
Dim SpPeni, UpPeni, SaldoAll, OstPenu, OstSht
Dim AddressFlat, RightAddress, nRow
Dim SignSaldoStart, SldRussia, SldKray, StartRow
Dim oExcel As Object
'
Set oExcel = CreateObject("Excel.Application")
'
NachAll = 0

'

YmAll = 0

'

DonaAll = 0

'

YpAll = 0

'

ReturnAll = 0

'

NachPeniAll = 0

'

SpPeni = 0

'

UpPeni = 0

'

SaldoAll = 0

'

II.

334
OstPenu = 0

'

OstSht = 0

'

' Microsoft Excel


oExcel.Application.Visible = True
' ( Excel 2003)
'
oExcel.Application.CommandBars("Standard").Visible = False
'
oExcel.Application.CommandBars("Formatting").Visible = False
'
oExcel.Application.WindowState = xlMaximized
' oExcel.Application.WindowState = xlNormal
' -
' oExcel.Application.Top = 65
' oExcel.Application.Left = 10
' oExcel.Application.Width = 470
' oExcel.Application.Height = 290
'
oExcel.WorkBooks.Add
'
'
oExcel.DisplayAlerts = False
' 75%
oExcel.ActiveWindow.Zoom = 75
' Excel
oExcel.Caption = " "
' , 1.5 , A4
oExcel.ActiveSheet.PageSetup.LeftMargin = 42
oExcel.ActiveSheet.PageSetup.RightMargin = 42
oExcel.ActiveSheet.PageSetup.TopMargin = 42
oExcel.ActiveSheet.PageSetup.BottomMargin = 42
oExcel.ActiveSheet.PageSetup.Orientation = xlLandscape
oExcel.ActiveSheet.PageSetup.PaperSize = xlPaperA4
' Excel-
oExcel.Cells.Font.NAME = "Arial"
oExcel.Cells.Font.Size = 7

10.

335

'
oExcel.Range("D1").Select
oExcel.ActiveCell.Font.Bold = True
oExcel.ActiveCell.Font.Size = 12
oExcel.ActiveCell.FormulaR1C1 = " "
oExcel.Range("C2").Select
oExcel.ActiveCell.VerticalAlignment = xlTop
oExcel.ActiveCell.Font.Size = 8
'
' RSset
With RSset
' RSset (Recordset)
' : SQL-
.Source = "SELECT * FROM tblStreet " & _
"WHERE STREET = " & SelectAddressStreet
'
.ActiveConnection = CurrentProject.Connection
.CursorType = adOpenKeyset

'

.Open
End With
'
' RSset . 14.8
If RSset(3) = False Then
'
RightAddress = Trim(RSset(2)) & " " & _
Trim(RSset(1))
Else
'
RightAddress = Trim(RSset(1)) & " " & _
Trim(RSset(2))
End If
RSset.Close '
AddressFlat = " : . Real Estate, " & _
RightAddress & ", " & _
Str(SelectAddressHouse) & ", . " & _
Str(SelectAddressFlat) & "."
'
oExcel.ActiveCell.FormulaR1C1 = AddressFlat

II.

336
oExcel.Range("A3").Select

oExcel.ActiveCell.VerticalAlignment = xlBottom
oExcel.ActiveCell.Font.Size = 3
' Copyright
oExcel.ActiveCell.FormulaR1C1 = "Copyright 2007 " & _
" < Real Estate> " & _
" " & _
" Microsoft Corporation: " & _
"MS Office Access 2007, MS Office Word 2007, " & _
"MS Office Excel 2007 " & _
"MS SQL Server 2005 Developer Edition"
'
oExcel.Range("A4").Select
oExcel.ActiveCell.FormulaR1C1 = ""
oExcel.Range("B4").Select
oExcel.ActiveCell.FormulaR1C1 = ""
oExcel.Range("C4").Select
oExcel.ActiveCell.FormulaR1C1 = ""
oExcel.Range("D4").Select
oExcel.ActiveCell.FormulaR1C1 = ""
oExcel.Range("E4").Select
oExcel.ActiveCell.FormulaR1C1 = "."
oExcel.Range("F4").Select
oExcel.ActiveCell.FormulaR1C1 = ""
oExcel.Range("G4").Select
oExcel.ActiveCell.FormulaR1C1 = ""
oExcel.Range("H4").Select
oExcel.ActiveCell.FormulaR1C1 = ""
oExcel.Range("I4").Select
oExcel.ActiveCell.FormulaR1C1 = ". "
oExcel.Range("J4").Select
oExcel.ActiveCell.FormulaR1C1 = " "
oExcel.Range("K4").Select
oExcel.ActiveCell.FormulaR1C1 = ". "
oExcel.Range("L4").Select
oExcel.ActiveCell.FormulaR1C1 = "."
oExcel.Range("M4").Select
oExcel.ActiveCell.FormulaR1C1 = "."

10.
oExcel.Range("N4").Select
oExcel.ActiveCell.FormulaR1C1 = "."
'
oExcel.Columns("A:A").ColumnWidth = 8
oExcel.Columns("B:B").ColumnWidth = 25
oExcel.Columns("C:C").ColumnWidth = 7
oExcel.Columns("D:D").ColumnWidth = 7
oExcel.Columns("E:E").ColumnWidth = 7
oExcel.Columns("F:F").ColumnWidth = 6
oExcel.Columns("G:G").ColumnWidth = 6
oExcel.Columns("H:H").ColumnWidth = 7
oExcel.Columns("I:I").ColumnWidth = 6
oExcel.Columns("J:J").ColumnWidth = 18
oExcel.Columns("K:K").ColumnWidth = 6
oExcel.Columns("L:L").ColumnWidth = 6
oExcel.Columns("M:M").ColumnWidth = 6
oExcel.Columns("N:N").ColumnWidth = 6
'
oExcel.Rows("4:4").Font.Bold = True
oExcel.Rows("4:4").RowHeight = 15
oExcel.Rows("4:4").Font.Size = 7
oExcel.Rows("4:4").VerticalAlignment = xlCenter
oExcel.Rows("4:4").Interior.ColorIndex = 8
oExcel.Rows("4:4").HorizontalAlignment = xlCenter
'
oExcel.Range("A4:N4").Select
oExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
'
With oExcel.Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
'
With oExcel.Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With

337

II.

338

'
With oExcel.Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
'
With oExcel.Selection.Borders(xlInsideVertical)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
'
With oExcel.Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
' -
RSset.Open "tblExcel", CurrentProject.Connection
nRow = 5 '
' : ,
SignSaldoStart = 0
SldRussia = 0
SldKray = 0
'
For I = 0 To RSset.RecordCount - 1
' I- RSset
RSset.Move I, adBookmarkFirst
Select Case RSset.Fields("CONTENTS").Value
Case " "
SignSaldoStart = 0
nRow = nRow + 1

' Excel

' . ModuleSlave
Call WriteLine(nRow, oExcel, RSset)
oExcel.Rows(Trim(Str(nRow)) & ":" & _
Trim(Str(nRow))).Font.Size = 7

10.
oExcel.Rows(Trim(Str(nRow)) & ":" & _
Trim(Str(nRow))).RowHeight = 13.2
oExcel.Rows(Trim(Str(nRow)) & ":" & _
Trim(Str(nRow))).HorizontalAlignment = xlCenter
oExcel.Range("A" & Trim(Str(nRow)) & ":" & _
"N" & Trim(Str(nRow))).Select
'
With oExcel.Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
'
With oExcel.Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
'
With oExcel.Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
'
With oExcel.Selection.Borders(xlInsideVertical)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
'
With oExcel.Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
SignSaldoStart = 1

339

II.

340
Case " .. "

SldRussia = RSset.Fields("SALDO").Value
Case " .. "
SldKray = RSset.Fields("SALDO").Value
If SignSaldoStart = 1 Then
'
nRow = nRow + 1
oExcel.Range("C" + Trim(Str(nRow))).Select
oExcel.ActiveCell.FormulaR1C1 = _
" ():

" & _

Trim(Str(SldRussia)) & _
" .

():

" & _

Trim(Str(SldKray)) & " ."


oExcel.Rows(Trim(Str(nRow)) & ":" & _
Trim(Str(nRow))).Font.Size = 7
oExcel.Rows(Trim(Str(nRow)) & ":" & _
Trim(Str(nRow))).Interior.ColorIndex = 35
nRow = nRow + 1
oExcel.Rows(Trim(Str(nRow)) & ":" & _
Trim(Str(nRow))).Interior.ColorIndex = 35
StartRow = nRow
End If
If SignSaldoStart = 0 Then
oExcel.Range("A" & Trim(Str(StartRow + 1)) & ":N" & _
Trim(Str(nRow))).Select
oExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With oExcel.Selection
.HorizontalAlignment = xlCenter
End With
With oExcel.Selection.Font
.Size = 7
End With
'
With oExcel.Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With

10.
'
With oExcel.Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
'
With oExcel.Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
'
With oExcel.Selection.Borders(xlInsideVertical)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
'
With oExcel.Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
'
' ,
If StartRow + 1 <> nRow Then
With oExcel.Selection.Borders(xlInsideHorizontal)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
End If
'
nRow = nRow + 1
oExcel.Range("B" & Trim(Str(nRow))).Select
oExcel.ActiveCell.FormulaR1C1 = " "
oExcel.Range("C" & Trim(Str(nRow))).Select

341

II.

342

oExcel.ActiveCell.FormulaR1C1 = NachAll
oExcel.Range("D" & Trim(Str(nRow))).Select
oExcel.ActiveCell.FormulaR1C1 = YmAll
oExcel.Range("E" & Trim(Str(nRow))).Select
oExcel.ActiveCell.FormulaR1C1 = DonaAll
oExcel.Range("F" & Trim(Str(nRow))).Select
oExcel.ActiveCell.FormulaR1C1 = YpAll
oExcel.Range("G" & Trim(Str(nRow))).Select
oExcel.ActiveCell.FormulaR1C1 = ReturnAll
oExcel.Range("I" & Trim(Str(nRow))).Select
oExcel.ActiveCell.FormulaR1C1 = NachPeniAll
oExcel.Range("K" & Trim(Str(nRow))).Select
oExcel.ActiveCell.FormulaR1C1 = SpPeni
oExcel.Range("L" + Trim(Str(nRow))).Select
oExcel.ActiveCell.FormulaR1C1 = UpPeni
oExcel.Rows(Trim(Str(nRow)) & ":" & _
Trim(Str(nRow))).Font.Size = 7
oExcel.Rows(Trim(Str(nRow)) & ":" & _
Trim(Str(nRow))).Interior.ColorIndex = 35
oExcel.Rows(Trim(Str(nRow)) & ":" & _
Trim(Str(nRow))).HorizontalAlignment = xlCenter
'
nRow = nRow + 1
StartRow = nRow
oExcel.Range("A" & Trim(Str(nRow))).Select
oExcel.ActiveCell.FormulaR1C1 = " " & _
" :

" & _

Trim(Str(SaldoAll)) & " . .." & _


" :
" .

" & Trim(Str(SldRussia)) & _

..

" . " & "

" & Trim(Str(SldKray)) & _

: " & _

Trim(Str(OstPenu)) & " . : " & _


Trim(Str(OstSht)) & " ."
oExcel.Rows(Trim(Str(nRow)) & ":" & _
Trim(Str(nRow))).Font.Size = 7
oExcel.Rows(Trim(Str(nRow)) & ":" & _
Trim(Str(nRow))).Interior.ColorIndex = 35
NachAll = 0

'

10.
YmAll = 0

'

DonaAll = 0

'

YpAll = 0

'

ReturnAll = 0

'

NachPeniAll = 0

'

SpPeni = 0

'

UpPeni = 0

'

End If
Case ""
SignSaldoStart = 0
nRow = nRow + 1
'
NachPeniAll = NachPeniAll + RSset.Fields("NPE").Value
'
SaldoAll = RSset.Fields("SALDO").Value
'
OstPenu = RSset.Fields("OSTPE").Value
'
OstSht = RSset.Fields("OSTSH").Value
'
Call WriteLine(nRow, oExcel, RSset)
Case Else
nRow = nRow + 1
'
Call WriteLine(nRow, oExcel, RSset)
'
NachAll = NachAll + RSset.Fields("NACH").Value
'
DonaAll = DonaAll + RSset.Fields("YPDONA").Value
'
YpAll = YpAll + RSset.Fields("YPVS").Value
'
ReturnAll = ReturnAll + RSset.Fields("VPE").Value
'
NachPeniAll = NachPeniAll + RSset.Fields("NPE").Value
'
SpPeni = SpPeni + RSset.Fields("YPNEDO").Value
'

343

II.

344

UpPeni = UpPeni + RSset.Fields("RAYPVO").Value


End Select
Next I
'
oExcel.Range("A1").Select
'
' -
'
' - !
oExcel.ActiveSheet.Protect ("' + Time() + '")
oExcel.ActiveWorkbook.Protect ("' + Time() + '")
RSset.Close
Set RSset = Nothing
End Sub


MS Excel, . "" . , , . .

, Excel-
. AccountExcel .
( , ).
. Recordset
(ADO):
Dim RSset As ADODB.Recordset

'

Set RSset = New ADODB.Recordset


With RSset
' RSset (Recordset)
' : SQL-
.Source = "SELECT * FROM tblStreet " & _
"WHERE STREET = " & SelectAddressStreet
'
.ActiveConnection = CurrentProject.Connection

10.
.CursorType = adOpenKeyset

345
'

.Open
End With

RSset (Recordset)
:
RSset.MoveFirst

'

RSset.MoveNext

'

RSset.MovePrevious

'

RSset.Move

'

RSset.MoveLast

'

( Move)
. 14.8. .
( )
, , :
SaldoAll = RSset.Fields("SALDO").Value
oExcel.ActiveCell.FormulaR1C1 = SaldoAll

Recordset.
Excel- Acess-, :
oExcel.ActiveCell.FormulaR1C1 = [Forms]![Flats]![txtFlat].Value

MS Excel
txtFlat Flats.

, ,
"Copyright " . !
.

10.2.
Microsoft Word 2007
Real Estate , , , ,

II.

346

. . .
.
, , - . , MS Word.
. Flats
, 10.5.
10.5.
Private Sub CommandTreaty_Click()
' ""
'
'
SelectAddressFlat = Me!txtFLAT.Value
'
SelectFlatRooms = Me!ROOMS.Value
'
If DCount("*", "tblOwners", _
"STREET = " & SelectAddressStreet & _
" AND HOUSE = " & SelectAddressHouse & _
" AND FLAT = " & SelectAddressFlat) = 0 Then
MsgBox " .", _
vbOKOnly + vbExclamation, ""
Else
'
DoCmd.OpenForm "Treaty"
End If
End Sub

Treaty
(. 10.4). ,
.
.
Word ( 10.6)
TreatyWord, ModuleSlave,
: , ,
. .

10.

. 10.4. Treaty
10.6. Word
Private Sub CommandSave_Click()
' ,
'
SelectDateTreaty = Me![txtDate].Value
' ,
SelectChief = Me![OptionGroup2].Value
'
SelectText = Me![txtSelectText].Value
' -
If IsNull(Me![CheckBox1].Value) Then
SelectMemorial = False
Else
SelectMemorial = Me![CheckBox1].Value
End If
'
SelectTypeFlat = Me![OptionGroup3].Value
'
SelectTypeKind = Me![OptionGroup3].Value
' ModuleSlave
Call TreatyWord(SelectDateTreaty, SelectChief, SelectText, _
SelectMemorial, SelectTypeFlat, SelectTypeKind)
End Sub

347

348

II.

, MS Excel, . , . ,
. , ,
Selection. MS Excel.
MS Excel Cell. MS Word . Selection,
. , Selection
.

. 10.5. Microsoft Word 12.0 Object Library


MS Access. MS Access "" MS Word, :
1. MS Access 2007. -

10.

349

2. Visual Basic, ,

.
3. VBA Tools. .
4. References. -

.
5. Microsoft Word 12.0 Object Library (. 10.5).
6. OK.

, , MS
Excel, . oWord,
. MS Word 10.7.
10.7. , MS Word
Public Sub TreatyWord(SelectDateTreaty, SelectChief, _
SelectText, SelectMemorial, SelectTypeFlat, _
SelectTypeKind)
' Microsoft Word
'
Dim I, SelectRoom, SelectRoom1, SelectRoom2, ChiefShot, _
ChiefLong, DayText, DayMonthYear, lcText, _
RightAddress, SelectHouse, SelectFlat
' Word
Dim oWord As Object
Dim RSset As ADODB.Recordset

'

Set RSset = New ADODB.Recordset


' ""
Select Case SelectFlatRooms
Case 1
SelectRoom = " "
SelectRoom1 = ""
SelectRoom2 = " "
Case 2
SelectRoom = " "
SelectRoom1 = ""
SelectRoom2 = " "

II.

350
Case 3

SelectRoom = " "


SelectRoom1 = ""
SelectRoom2 = " "
Case Else
SelectRoom = Str(SelectFlatRooms) + " "
SelectRoom1 = Str(SelectFlatRooms) + " "
SelectRoom2 = Str(SelectFlatRooms) + " "
End Select
Select Case SelectChief
Case 1
ChiefShot = " .."
ChiefLong = " "
Case 2
ChiefShot = " .."
ChiefLong = " "
End Select
'
DayMonthYear = ""
' ModuleSlave
Call Detail(SelectDateTreaty, DayMonthYear)
' SelectDateTreaty -
' DayMonthYear -
' MS Word
Set oWord = CreateObject("Word.Application")
' MS Word
oWord.Visible = True
' MS Word
oWord.Caption = " "
oWord.Documents.Add
' , 4
' (1 = 28 )
With oWord.ActiveDocument.PageSetup
.LineNumbering.Active = False
.Orientation = wdOrientPortrait
.LeftMargin = 48
.RightMargin = 40

10.
.TopMargin = 56
.BottomMargin = 56
End With
'
With oWord.ActiveDocument
.AutoHyphenation = True
.HyphenateCaps = True
.ConsecutiveHyphensLimit = 0
End With
With oWord.Selection
'
.Font.NAME = "Times New Roman"
.Font.Size = 14
.Font.Bold = wdToggle
.ParagraphFormat.Alignment = wdAlignParagraphCenter
.TypeText ("")
.TypeParagraph
.Font.Size = 12
lcText = " "
.TypeText (lcText)
If SelectMemorial = True Then
' -
.TypeParagraph
lcText = " - "
.TypeText (lcText)
End If
.TypeParagraph
.Font.Size = 12
.Font.Bold = wdToggle
.ParagraphFormat.Alignment = wdAlignParagraphJustify
.TypeText (". Real Estate")
.TypeParagraph
.ParagraphFormat.Alignment = wdAlignParagraphCenter
lcText = Trim(DayMonthYear) '
.TypeText (lcText)
'
If Len(Trim(SelectText)) <> 0 Then
.TypeParagraph

351

II.

352

.ParagraphFormat.Alignment = wdAlignParagraphJustifyMed
lcText = "

" & Trim(SelectText)

.TypeText (lcText)
End If
.TypeParagraph
.ParagraphFormat.Alignment = wdAlignParagraphJustifyMed
lcText = "

Real Estate " & _

" " & ChiefLong & _


" " & _
", " & _
"31.12.2000 1000, " & _
", c ."
.TypeText (lcText)
.TypeParagraph
.Font.Bold = wdToggle
.Font.Underline = wdUnderlineSingle
.ParagraphFormat.Alignment = wdAlignParagraphCenter
' RSset
With RSset
' RSset (Recordset)
' : SQL-
.Source = "SELECT * FROM tblOwners " & _
"WHERE STREET = " & SelectAddressStreet & _
" AND HOUSE = " & SelectAddressHouse & _
" AND FLAT = " & SelectAddressFlat
'
.ActiveConnection = CurrentProject.Connection
.CursorType = adOpenKeyset

'

.Open
End With
'
For I = 0 To RSset.RecordCount - 1
' I-
RSset.Move I, adBookmarkFirst
'
' RSset
lcText = Trim(RSset(4)) & " " & _
Trim(RSset(5)) & " " & _

10.

353

Trim(RSset(6)) & " - " & Str(RSset(7)) & " .."


.TypeText (lcText)
.TypeParagraph
Next I
If RSset.RecordCount > 0 Then
' ,
' 0
Select Case SelectTypeKind
Case 1
lcText = "( )"
Case 2
lcText = "( )"
Case 3
lcText = "( )"
End Select
.TypeText (lcText)
End If
RSset.Close '
.TypeParagraph
.TypeParagraph
.Font.Bold = wdToggle
.Font.Underline = wdUnderlineNone
.ParagraphFormat.Alignment = wdAlignParagraphJustify
lcText = " , " & _
" :"
.TypeText (lcText)
.TypeParagraph
With RSset
' RSset (Recordset)
' :
.Source = "SELECT * FROM tblFlats " & _
"WHERE STREET = " & SelectAddressStreet & _
" AND HOUSE = " & SelectAddressHouse & _
" AND FLAT = " & SelectAddressFlat
'
.ActiveConnection = CurrentProject.Connection
.CursorType = adOpenKeyset
.Open
End With

'

II.

354

RSset.MoveFirst '
If SelectTypeFlat = 1 Then
'
lcText = "

1. , " & _

" , " & _


" " & Trim(SelectRoom) & " " & _
Trim(Str(RSset(5))) & _
" . ., " & _
Trim(Str(RSset(6))) & " . ., : "
Else
'
lcText = "

1. , " & _

" " & _


" " & Trim(Str(RSset(5))) & _
" . ., " & _
Trim(Str(RSset(6))) & " . . " & _
" " & Trim(SelectRoom2) & _
" " & Trim(Str(RSset(5))) & _
" . ., " & _
Trim(Str(RSset(6))) & " . . " & _
" , " & _
" , : "
End If
.TypeText (lcText)
RSset.Close '
lcText = ". Real Estate, "
'
' RSset
With RSset
' RSset (Recordset)
' :
.Source = "SELECT * FROM tblStreet " & _
"WHERE STREET = " & SelectAddressStreet
'
.ActiveConnection = CurrentProject.Connection
.CursorType = adOpenKeyset
.Open
End With

'

10.
'
' RSset . 14.8
If RSset(3) = False Then
'
RightAddress = Trim(RSset(2)) & " " & Trim(RSset(1))
Else
'
RightAddress = Trim(RSset(1)) & " " & Trim(RSset(2))
End If
lcText = lcText & RightAddress & _
", " & Trim(SelectAddressHouse) & ", . " & _
Trim(Str(SelectAddressFlat)) + "."
RSset.Close '
.Font.Underline = wdUnderlineSingle
.Font.Bold = wdToggle
.TypeText (lcText)
.TypeParagraph
.Font.Bold = wdToggle
.Font.Underline = wdUnderlineNone
.ParagraphFormat.Alignment = wdAlignParagraphJustifyMed
lcText = "

2. " & _

" " & _


" . "
.TypeText (lcText)
.TypeParagraph
lcText = "

3. , " & _

" , ."
.TypeText (lcText)
.TypeParagraph
lcText = "

4. " & _

" " & _


" ."
.TypeText (lcText)
.TypeParagraph
lcText = "

5. " & _

" " & _


" , " & _
" ."

355

II.

356

If SelectMemorial = True Then


lcText = lcText & " " & _
" " & _
" 16.09.1982 865."
End If
.TypeText (lcText)
.TypeParagraph
.ParagraphFormat.Alignment = wdAlignParagraphJustifyMed
lcText = "

6. " & _

", " & _


", - , " & _
" " & _
" " & _
" ."
.TypeText (lcText)
If SelectMemorial = True Then
.TypeParagraph
lcText = "

7. " & _

" " & _


" - " & _
" " & _
" ."
.TypeText (lcText)
End If
.TypeParagraph
.TypeParagraph
.ParagraphFormat.Alignment = wdAlignParagraphCenter
.Font.Bold = wdToggle
lcText = " :"
.TypeText (lcText)
.TypeParagraph
.TypeParagraph
lcText = " "
.ParagraphFormat.Alignment = wdAlignParagraphJustify
.Font.Bold = wdToggle
.TypeText (lcText)
.TypeParagraph
'

10.

357

.ParagraphFormat.Alignment = wdAlignParagraphRight
lcText = " "
.TypeText (lcText)
.TypeParagraph
.TypeParagraph
.Font.NAME = "Courier new"
.Font.Size = 12
.ParagraphFormat.Alignment = wdAlignParagraphJustify
lcText = "________________ "
.TypeText (lcText)
.Font.Bold = wdToggle
lcText = Trim(ChiefShot)
.TypeText (lcText)
End With
'
oWord.ActiveWindow.ActivePane.VerticalPercentScrolled = 0
Set RSset = Nothing
End Sub

TreateWord Detail, , .
ModuleSlave,
.

11



, .
HTML Help Workshop.
Microsoft. Visual FoxPro 6.0.
- .
Web- :
http://www.microsoft.com/workshop/author/htmlhelp
HTML Help Workshop 1.3.
ReadMe, . HTML
Help Workshop .
.
HTML Help Workshop Internet Explorer. HTML Help
Workshop chm. -
. ,
, <F1>.
RealEstate.chm .

11.1. HTML-
HTML-.
HTML HELP.

11.

359

HTML- Microsoft Word. .



. :
1. Microsoft Word .
2. . .
3. .
4. -

Microsoft Word ,
.
,
, ,
:
1. Microsoft Word , -

.
2. -

. (. 11.1).
3. .
4. .

. 11.1. - Microsoft Word

HTML. Microsoft Word ,


-. : -. ! : -
. .
HTML-. ,
.

360

II.

11.2.
HTML Help Workshop. File
(). New (). New. Project () OK.
HTML Help Workshop
. . RealEstate.hhp.

11.3. HTML-
RealEstate.hhp. Project
() (. 11.2).

. 11.2. RealEstate.hhp HTML Help Workshop

11.

361


Add/Remove topic files (
HTML-).
HTML-.

).

Change project options (-

Options () .
General () :
;
,

;
.

Files () , .
Compiler () . 11.3. .

. 11.3.

362

II.

11.4.


HTML Help Workshop Contents ().
11 (. 11.4).
Contents properties
( )
. (
). .

Insert
a heading ( ).

Insert a page ( ).
.
.

. 11.4. HTML Help Workshop Contents

11.

363

.
. - .
. Save all files and compile
,
( ) Project ()
HTML Help Workshop.
RealEstate.chm HTML Introduction ().

. 11.5. <F1> HTML-

364

II.

, ,
MS Access
HTML-. , ,
. ,
HelpContextID ( ) RealEstate.h.
. 11.5.

11.5.
, , HtmlHelp API information
(. 11.6),
Project () HTML Help Workshop.

. 11.6. HtmlHelp API Information

Alias (). Add


() Alias. ,

11.

365

. . HTML- . ,
.
HTML- .
.
. "A1"
"" . :
Form_Building

( )

Form_Building_Combo1_Street

( )

11.6.
( HelpContextID MS Access).
MS Access. . Form, CheckBox, ComboBox, CommandButton, EditBox, Grid, Image, Label, ListBox, Page . HelpContextID .
. , , .
Real Estate , .

:
Private Sub Form_Load()
'
Me.HelpFile = CurrentPath() & "\RealEstate.chm"
End Sub

11.7.
.
Map-. h. RealEstate.h. Windows . RealEstate.h:
#define Form_Login 100

// Login HTML\Part 04_2_1.htm

#define Form_Access 101 // Access HTML\Part 04_2_2.htm


#define Form_Street 104 // Street HTML\Part 04_3_3.htm

366

II.

, //,
.
RealEstate.hhp.
HTML Help Workshop. .
Project. HtmlHelp API information
(. 11.7). Map- RealEstate.h.

. 11.7.
HtmlHelp API information

11.8.
,
Save
all files and compile ( ) Project () (. . 11.2).

11.

367

HTML Help Workshop 1.3 ( 4.74.8702.0)


Microsoft Word png (Portable Network
Graphics).

PNG , Web. .
PNG ,
.

, ( ) . PNG-
HTML-.
RealEstate.hhp [FILES]:
[FILES]
HTML\Part 02.files\*.png
HTML\Part 03_3.files\*.png
HTML\Part 04_1.files\*.png
HTML\Part 04_2.files\*.png
HTML\Part 04_2_4.files\*.png
HTML\Part 04_3_3.files\*.png
HTML\Part 05_2.files\*.png
HTML\Part 06.files\*.png

III


"-"

,
, ,

12


MS Access 2007
MS SQL Server 2005

, ,
. Microsoft Access , . . , , , , , ,
, .
.
. "-" , , , ,
.
Microsoft SQL Server "", ,
. , ,
, . . SQL Server .
.
, , "-" .

372

III. "-"

, MS Office
Access 2007 ( accdb) . , . , , , .
. "" . !
,
MS Access . ,
MS Access
, .
"" <Shift> .
.
1. SQL Server 2005. -

.
2. , (.

8).
3. -

ACCDE ( VBA) ADE ( MS


Access ).
4. SQL Server 2005, -

: .
,
. , (
), , "-" .

12.1. SQL Server 2005


SQL Server 2005 Microsoft . -

12. MS Access 2007 MS SQL Server 2005

373

. .
. . . ,
, SQL Server
(Developer Edition) (Workgroup Edition Standard Edition). ,
, ,
Developer Edition, Express Edition. MS SQL Server 2005.
Enterprise Edition SQL Server.

.
.
Windows Server 2003 Enterprise Edition Standard Edition. ,
, - .
Developer Edition .

Enterprise Edition .
Microsoft Windows 2000 SP4 Microsoft Windows XP SP1.
.
Enterprise Edition.
Enterprise Edition 120-day Evaluation .

Microsoft. ,
.
Microsoft Windows XP SP1.
Standard Edition , Enter-

prise Edition. . , ,
.
Enterprise Edition.
Workgroup Edition Microsoft. MS SQL Server

2000, , .
, , . .
Windows, Windows 2000, .

374

III. "-"

Express Edition Visual Studio .NET 2005 -

, "" Microsoft. . MSDE


SQL Server 2000. (4
).
Mobile Edition Tablet PC.

. Microsoft: "MS SQL Server


".
MS SQL Server 2005, , .

12.2.
MS SQL Server 2005 Developer Edition
MS SQL Server 2005 , Service Pack 1 Windows Server 2003
Service Pack 2 Windows XP?
DVD-. . (. 12.1).

. 12.1. MS SQL Server 2005

12. MS Access 2007 MS SQL Server 2005

375

12.2.1.
Microsoft, (. 12.2), Windows Installer. MS SQL Server 2005 . , SQL
Server
Windows.
, Microsoft Windows Installer 3.1. . . Microsoft (
2,46 ).

""
Windows . MS
SQL Server 2005 , Windows
Vista, "" Installer 3.1 .

. 12.2.
-

.NET Framework 2.0 MS SQL Server 2005 (Microsoft SQL Native


Client Microsoft SQL Server 2005 Setup Support Files).
System Configuration Checker MS SQL Server
2005 . . . .

376

III. "-"

12.2.2.
,

(. 12.3).
SQL Server Database Services . -

. , .

. 12.3. MS SQL Server

Analysis Services SQL Server

(OLAP),

12. MS Access 2007 MS SQL Server 2005

377

,
.
.
.
Reporting Services .

.
MS SQL Server, , OLE DB. Web. . 12.3 , . .
MS SQL- IIS (Internet
Information Services).
Notification Services . -


SQL Server.
Integration Services

,
, SQL Server 2005.
Workstation components, Books Online and development tools -

SQL Server .
, . .
, ,

.

12.2.3.
MS SQL Server 2005
MS SQL Server
2005, .
. . Default instance (. 12.4).
. MS SQL Server 2000 Named instance , . MS SQL Server 2005 .
.
MS SQL Server 2005 Developer Edition 50 .

378

III. "-"

. 12.4. MS SQL Server


, , , Master. MS SQL Server . Master.


. ,
Department. MS SQL Server 2005
: Master\Department.

12.2.4.
SQL Server
: SQL Server
(SQL Server Agent, Analysis Services .) -

12. MS Access 2007 MS SQL Server 2005

379

?
? ,
. 12.5. MS
Access . SQL- .

. 12.5.

12.2.5.
MS SQL- :
Windows SQL Server (. 12.6).
,

380

III. "-"

SQL-. ? Windows
. . Microsoft ( Windows). ,
, Mixed Mode.

. 12.6.


.
,
SQL Server ( sa) .

12. MS Access 2007 MS SQL Server 2005

381

SQL Server 2005


SQL Server
Management Studio.

12.2.6.
, Collation Settings (. 12.7), .
,
. , .
Binary, MS SQL Server , .
Case - sensitive SQL Server ,
, . ,
(tblBUILDING), :
SELECT * FROM tblBUILDING

, , , . . tblBuilding.

Case - sensitive
"" , , . . SQL- MS Access
, MS SQL Server . ?
, , ,
.

Reporting Services, . .
. Ready to Install (. 12.8)
, Install -

382

III. "-"

, 1520, . , , .
, - , Back .
, . Install .
MS SQL Server 2005
. Finish
. Microsoft SQL
Server 2005.

. 12.7.

12. MS Access 2007 MS SQL Server 2005

383

. 12.8.

12.3.

MS Access MS SQL Server MS Access. SQL Server,
Microsoft Access 2007,
MS Access 2007 Microsoft
SQL 2005 .
Microsoft Office, Access, Microsoft. MS Access 97 "" SQL
Server 7.0, MS Access 2000 SQL Server 2000.

384

III. "-"

MS Office, . MS Access 2003 c SQL Server 2005.


Access SQL Server :
1. , ,

Access .
2. ,

SQL Server. ,
.
3. . SQL Server

( ), . .
. , MS Access SQL
Server . .
SQL Server
Microsoft Access.
Microsoft SQL Server.

,
. SQL Server ,
(sa).
, ODBC Microsoft SQL Server. , SQL Server (, Visual FoxPro
Delphi). , ODBC (Open Database Connectivity, ) , , . MS Access MS SQL
Server, ODBC .
:
1. Microsoft Access 2007.
2.

MS Access.
3. SQL Server.
4. .

12. MS Access 2007 MS SQL Server 2005

385

12.3.1.

SQL Server . SQL Server
,
.

12.3.2.
(. 12.9) SQL Server, , . Microsoft SQL Server 2005 Developer Edition , Master, .

. 12.9. SQL Server

, , Microsoft

386

III. "-"

Access 2007 SQL Server ,


, .
SQL Server
sa, SQL Server
.
.
.
SQL Server 2005. . 12.5,
Service Account .
, "SQL"
Microsoft Access 2007 Real Estate. (Real
EstateSQL) .

12.3.3.
Microsoft
Access, Real EstateSQL .
. . ,

.

12.3.4.
(. 12.10). , . ,
, , . .
,
SQL Server.
.

,
SQL Server .
Microsoft Access ,
Microsoft SQL Server SQL Server.
SQL Server
Access, "aaaaa". Microsoft Access
,
"aaaaa" . -

12. MS Access 2007 MS SQL Server 2005

387

, ,
"_". Microsoft Access SQL Server.

. 12.10.

SQL Server , , .

. ,

CHECK. , , . ,

ANSI (American National Standards Institute), , -

III. "-"

388

SQL Server. SQL Server, MS Access, .


. Microsoft SQL Server

timestamp ( ) . Access timestamp,


, .
, .
.

timestamp SQL Server


, , ,
.

, ,
SQL Server timestamp SQL Server, Microsoft Access, "
(4 8 )", Memo OLE.

timestamp
, ,
. ,
. Access,
Memo, OLE
, .


. , MS SQL Server TransactSQL, MS SQL Server . MS Access .
!
.


, , DRI (Declarative
Referential Integrity, ). DRI
, Microsoft Access,

12. MS Access 2007 MS SQL Server 2005

389

( ""
"--") ( "" "--").

DRI
MS SQL Server.
.
tblBuilding tblDistrict. . 12.11 , MS Access.
, , .
. , :

tblDistrict
tblBuilding;

tblDistrict
tblBuilding .

. 12.11. ,
tblDistrict tblBuilding MS Office Access 2007

390

III. "-"

. 12.12.
tblDistrict tblBuilding MS SQL Server 2005,
DRI

. 12.12
tblBuilding tblDistrict
DRI. MS SQL Server , MS Access. ,
, . ,
, tblBuilding,
,
(MS Access)
tblDistrict.

12. MS Access 2007 MS SQL Server 2005

391

( Enforce Foreign Key Constraint Yes);

tblDistrict
tblBuilding (Update Rule Cascade);

tblDistrict
tblBuilding (Delete Rule No Action).

.
.

. 12.13. tblDistrict tblBuilding


MS SQL Server 2005,

III. "-"

392

. Microsoft
Access ,
,


,
. .
,

. , .
. 12.13 , tblBuilding
tblDistrict : Enforce
Foreign Key Constraint No ( ). . .

12.1 , Transact-SQL
tblDistrict,
tblBuilding , .
12.1. ( tblDistrict)
ALTER TRIGGER T_tblDistrict_DTrig
ON tblDistrict FOR DELETE AS
SET NOCOUNT ON
/* * 'tblBuilding' */
IF (SELECT COUNT(*) FROM deleted, tblBuilding
WHERE (deleted.DISTRICT = tblBuilding.DISTRICT)) > 0
BEGIN
RAISERROR 44445 '
. "tblBuilding"
,
.'
ROLLBACK TRANSACTION

12. MS Access 2007 MS SQL Server 2005

393

END

12.2 , tblBuilding, tblDistrict.


12.2. ( tblDistrict)
ALTER TRIGGER T_tblDistrict_UTrig
ON tblDistrict FOR UPDATE AS
SET NOCOUNT ON
/* * 'tblBuilding' */
IF UPDATE(DISTRICT)
BEGIN
UPDATE tblBuilding
SET tblBuilding.DISTRICT = inserted.DISTRICT
FROM tblBuilding, deleted, inserted
WHERE deleted.DISTRICT = tblBuilding.DISTRICT
END

12.3 ,
tblBuilding, tblDistrict.
12.3. ( tblBuilding)
ALTER TRIGGER T_tblBuilding_ITrig
ON tblBuilding FOR INSERT AS
SET NOCOUNT ON
/* * 'tblDistrict' */
IF (SELECT COUNT(*) FROM inserted) !=
(SELECT COUNT(*) FROM tblDistrict,
inserted WHERE (tblDistrict.DISTRICT = inserted.DISTRICT))
BEGIN
RAISERROR 44447 '
.

"tblDistrict".'
ROLLBACK TRANSACTION

III. "-"

394
END



,
. , , . 12.14.

. 12.14.

SQL Server Management Studio . , ,


, "" "-". ,
.

SQL Server 2005 ,


, "" "" .

12.3.5.
(. 12.15). ,
, .
SQL
Server 2005.

12. MS Access 2007 MS SQL Server 2005

395

, .
Access "-" ( -

OLE DB).
SQL Server . -

MS Access SQL
Server, "-"
( ODBC).
.

MS Access 2007 SQL Server.


, ,
, ( .NET). ,
, . , , .

. 12.15.
SQL Server

396

III. "-"

. . .

12.3.6.
"-"
Access "" SQL Server
Microsoft Access (. 12.16).
( MS Access).
"CS", ,
Access. Microsoft Access
2007 Microsoft SQL Server 2005 OLE DB. : , , ,
. . SQL-.
, , .
MS Access 2007
Access , .

. 12.16. Microsoft Access

SQL Server ,
,

12. MS Access 2007 MS SQL Server 2005

397

SQL Access Transact-SQL SQL Server. .


,
( ,
ORDER BY,
ORDER BY, ). , , , .
,
. SQL, .

,
SQL Server
, , , SQL , , SQL Server.


. , , (DAO) ActiveX (ADO),
( SQL Server SQL
(Data Definition Language).

12.3.7. Access-
SQL Server
SQL Server Access, . , . . Microsoft Access
Microsoft SQL-,

III. "-"

398

Access SQL SQL Server, Transact-SQL. . accdb- ,


Real Estate .
Real Estate.accdb. MS Access
.
Real Estate , . 12.17.

. 12.17. MS Access
:
SQL Server

. :
ODBC;DRIVER=SQL Server;SERVER=master;
APP=2007 Microsoft Office system;
DATABASE=Real EstateSQL;Trusted_Connection=Yes;
TABLE=dbo.tblStreet

12. MS Access 2007 MS SQL Server 2005

399

ODBC (Open Database Connectivity). . ODBC, MS Access .


.
?
DRIVER ODBC ( SQL Server

C:\Windows\system32\sqlsrv32.dll).
SERVER SQL Server ( master). -

, . . SQL Server 2005


.
APP (Microsoft Office).
DATABASE , .
TABLE .

.
. ?
.
!
ODBC . SQL Server. :
ODBC;DSN=Sql2005;Description=Access2007SqlServer2005;
APP=2007 Microsoft Office system;
DATABASE=Real EstateSQL;LANGUAGE=;Trusted_Connection=Yes;
TABLE=dbo.tblStreet

:
DSN ;
Description .

,
( );
LANGUAGE SQL-.

400

III. "-"

ODBC
SQL Server . Real Estate.accdb,
. , ,
"" MS SQL Server 2005 Master. ( ) MS Access 2007 ,
, .

1.
1. .
2. .

.
. .
3. ( ). ,

<Shift>, .
4. <Delete>.

.
5. .

6. . ODBC.
7. ODBC.
8.

2.
. ODBC
. , , SQL-, . .

12. MS Access 2007 MS SQL Server 2005

401

3.
ODBC.
.
1. : . -

.
.
2. . SQL Server

( C:\Windows\system32\sqlsrv32.dll).
.
3. ODBC -

. .

4.
(. 12.18) :
,

;
,

, ;
SQL Server 2005.

, . ,
, SQL Server.
Windows NT, SQL Server
, . SQL Server
SQL Server.
. 12.6 SQL Server 2005. (. 12.19) ,
.
. .
. (, )
.

402

III. "-"

. 12.18.

. 12.19.

12. MS Access 2007 MS SQL Server 2005

403

5. ODBC
Microsoft ODBC , (. 12.20).
. . Sql2005 OK.

. 12.20.

6.
Real
EstateSQL, SQL Master.
, . OK. MS Access 2007
. .

404

III. "-"

12.3.8. SQL Server



. SQL Server,
Microsoft Access .
(. . 12.15). MS SQL Server 2005 .
.

12.3.9.
SQL Server
MS SQL
Server (. 12.21).

. 12.21. SQL Server

12. MS Access 2007 MS SQL Server 2005

405

, . Microsoft Access 2007


. .
.
- . .
HTML. Real
Estate - .
14.

12.4. ODBC, OLE DB, DAO, ADO, ADO.NET


.NET
MS Office Access 2007
SQL Server 2005 : ODBC, OLE DB .NET. . .
. . -


. . .
ODBC. .

API (Application Programming Interface) . ODBC


API .
. .
OLE DB. 20012003 ODBC. -


. Microsoft Access 2007 OLE DB
. ODBC
, -

406

III. "-"

. ,
, Microsoft ( ),
ODBC . OLE DB API,
COM (Component Object Model, ).
, OLE DB,
. COM-.
2002 Microsoft .NET. :
.NET . , , Web-.
Microsoft .NET CLR
(Common Language Runtime). .NET , . ,
, C++, , Visual Basic Delphi.
: DAO,
ADO, ADO.NET . VBA , MS Visual
Studio .NET, ,
(DAO, ADO ADO.NET) .
(, MS Visual FoxPro)
. .
Microsoft DAO (Data Access Objects)

, VBA. Jet (MS Access) ODBC.


Microsoft ADO (ActiveX Data Objects) DAO

OLE DB.
Microsoft ADO.NET (ActiveX Data Objects .NET) -

ADO. OLE DB,


. ADO.NET
.NET.
. 12.22 MS SQL-
, .

12. MS Access 2007 MS SQL Server 2005

407

. 12.22. MS SQL-

MS Access 2007 ( accdb) Ace, Jet (. 12.23). MS Access


2007 .NET, .NET.

. 12.23. MS Access

. 12.3.7
MS Access 2007 "-"
SQL Server 2005. . 12.24.

. 12.24. MS Access 2007 SQL Server


""

408

III. "-"

Microsoft,
,
( adp) Access
2002/2003 MS Office Access
.
MS Office 2007
MS Access Office .NET. , . MS Access 2007 MS SQL Server
2005 Express Edition Microsoft. .

13

" "
MS SQL Server 2005
MS SQL Server .
:
, .
MS SQL Server .

13.1.
MS SQL Server Management Studio
MS SQL Server 2005
.
SQL Server Management Studio. Visual Studio .NET. SQL Server Management Studio .
: | | Microsoft SQL Server 2005 | SQL
Server Management Studio. Connect to Server (
). , , . Connect (). ,
. 13.1.
SQL Server Management Studio .
View () .
Object
Explorer. SQL-.
, , , . .

410

III. "-"

. Filter () . , , .

View. .

. 13.1. Microsoft SQL Server Management Studio

Registered Servers
. MS
SQL-, ,
SQL Server Management Studio, .
.
Registered Servers New () Server Registration ( ).
Template Explorer
.
Create (), Alter () Drop () . , , .
36 . .

13. " " MS SQL Server 2005

411

sql .
:
C:\Program Files\Microsoft SQL Server\90\Tools\Binn\VSShell\Common7\
IDE\sqlworkbenchprojectitems\Sql

Solution Explorer
SQL-.
Properties Windows
. : .
.

13.2.
, ,
Real EstateSQL. SQL Server 2005?
, MS Access 2007!
. :
1. Object Explorer

.
2. , ""

, .
3. Database Diagrams (-

).
4. New Database

Diagrams ( ).
5. . , -

. ,
tblUser. , .
6. Close () . -

. 13.2.
, MS Access 2007:
;
;

III. "-"

412

, ,

;
;
;
.

. 13.2. Real EstateSQL

13.3. MS SQL Server 2005


SQL Server 2005 "Schema". , , , . .
Real Estate, ,
. . dbo, " ".

13. " " MS SQL Server 2005

413

SQL Server . .
.
Windows. .
.
.

,
,
MS SQL Server 2005.

:
1. Object Explorer

.
2. , ""

, .
3. Security ().

Schemas (). .
4. New Schema ( ). ,

.
5. General () Schema name ( )

. Schema Owner ( )
.
6. Search (). -

OK.

. , , .
.

414

III. "-"

13.4.
.
. . :
<__>.<_>.<_>

tblStreet :
[Real EstateSQL].dbo.tblStreet

Real EstateSQL - , .
, dbo ( ) , , :
tblStreet.

13.4.1.
SQL Server Management Studio :
1. Object Explorer Databases

( ), .
2. Tables () -

. New Table (
).
3. (. 13.3). -

. .
Table () . : Column Name, Data
Type
Allow Nulls.
Column
Properties . , ( ).

13. " " MS SQL Server 2005

415

Description () Column
Properties ( ).
, , .
, .

Table,
, Column Properties. Decimal Column Properties
: Precision Scale,
.

. 13.3. tblBuilding
SQL Server Management Studio

III. "-"

416

Properties () . Name () Description () . , ,


Schema (). Save ()

, .

13.4.2.
MS SQL Server Management Studio
. :
1. Object Explorer

.
2. , ""

, .
3. Tables ().
4. ,

.
5. Properties

().
6. Table Properties ( ).

: General, Permissions
Extended Properties. :
( Data

space);
, ( -

Index space).
( Row count);
( DateCreated);
( LastUpdated);
;
.

13. " " MS SQL Server 2005

417

13.4.3. ,

Transact-SQL. :
1. MS SQL Server Management Studio,

.
2. Standard -

New Query.
3.

.
Object Explorer ( ) New Query
( ).
4. (. 13.4).

. , .
. , Execute (), , .
: Results () Messages ().
tblBuilding
dbo Inspector.
SELECT * INTO Inspector.tblBuilding FROM dbo.tblBuilding

Messages () :
(30 row(s) affected)

:
1. Object Explorer Databases

( ), .
2. Tables () -

. View Dependencies
( ).
. . .

III. "-"

418

3. -

Delete ().
4. -

Rename ().

. 13.4. MS SQL Server Management Studio

13.4.4.
:
MS SQL Server Management Studio -

Transact-SQL;
c MS SQL Server Management Studio, -

Object Explorer ;

13. " " MS SQL Server 2005

419

, ""
, ;

Tables ();

,
;

Open
Table ( );

Table ().
.

Transact-SQL , (. . 13.4).

13.5. MS SQL Server 2005


MS SQL-
. , . , . . 13.1 .
13.1. MS SQL Server 2005

bit

0, 1 Null

tinyint

0 255

smallint

32 768 32 767

int

2 147 483 648


2 147 483 647

bigint

263 263

decimal

517

1038 1038

III. "-"

420

13.1 ()

real

3.41038 3.41038

float

48

1.7910308 2.2310308

money

922 337 203 685 477.5808


922 337 203 685 477.5807

smallmoney

214 748.3648
214 748.3647

smalldatetime

1 1900
6 2079
1

datetime

1 1753
31 9999
3,33

xml

XML

char

( Unicode)
8000

varchar

1
+ 2

( Unicode)
8000

varchar(max)

1
+ 2

( Unicode)
2 147 483 647

text

( Unicode)
2 147 483 647

nchar

(Unicode)
4000

13. " " MS SQL Server 2005

421

13.1 ()

nvchar

2
+
2

(Unicode)
4000

nvchar(max)

2
+
2

(Unicode)
1 073 741 823

ntext

(Unicode)
1 073 741 823

binary

8000

varbinary


+
2


8000

varbinary(max
)


+
2


2 147 483 647

image


2 147 483 647

MS SQL Server 2005 xml,


, XML. . : varchar(max),
nvchar(max), varbinary(max).
2 .

13.6.

. , , MS SQL Server

III. "-"

422

int,
int, tinyint smallint. ,
,
CAST() CONVERT(). Transact-SQL, . .
CAST:
CAST(expression AS data_type [ (length ) ])

CONVERT:
CONVERT(data_type [ ( length ) ], expression [, style ] )

:
expression , Transact-SQL, ;
data_type , -

;
length ( );
style

.
CAST . 13.5.

. 13.5. 3.1415926
int

3.1415926, :
SELECT CAST(3.1415926 AS money)

: 3.1416.

13. " " MS SQL Server 2005

423

CONVERT()
" " .
, .
style (. 13.2).
13.2. CONVERT()
(yy)


(yyyy)

"/"

0 100

mon dd yyyy
hh:miAM ( PM)

101

mm/dd/yyyy

102

ANSI

yy.mm.dd

103

dd/mm/yy

104

dd.mm.yy

105

dd-mm-yy

106

dd mon yy

107

Mon dd, yy

108

hh:mm:ss

9 109

mon dd yyyy
hh:mi:ss:mmmAM ( PM)

10

110

mm-dd-yy

11

111

yy/mm/dd

12

112

ISO

yymmdd

13 113

dd mon yyyy
hh:mm:ss:mmm
(24- )

14

114
20 120

hh:mi:ss:mmm
(24- )

ODBC

yyyy-mm-dd
hh:mi:ss
(24- )

III. "-"

424

13.2 ()
(yy)


(yyyy)

"/"

21 121

ODBC

yyyy-mm-dd
hh:mi:ss.mmm
(24- )

126

ISO8601

yyyy-mm-dd
Thh:mm:ss.mmm
(no spaces)

127

ISO8601 Z

yyyy-mmddThh:mm:ss.mmmZ
( )

130

Hijri (

)

dd mon yyyy
hh:mi:ss:mmmAM

131

Hijri (

)

dd/mm/yy
hh:mi:ss:mmmAM

:
;
( );
;
( ).
SELECT GETDATE(),
CONVERT(CHAR(12),GETDATE(),4),
CONVERT(CHAR(24),GETDATE(),109),
CONVERT(CHAR(10),GETDATE(),108)

------

!Execute ------

2007-05-25 10:13:51.577
25.05.07
May 25 2007 10:13:51:577
10:13:51

13. " " MS SQL Server 2005

425

13.7. Transact-SQL
MS SQL Server 2005
Transact-SQL,
SQL (Structured Query Language) ANSI SQL-92. , Transact-SQL ,
. Transact-SQL.

13.7.1.
Transact-SQL , , , , , ,
. . . :
: @, $, _, #;
128 ;
, , , &,

, : ^, !, %, -, ", \, ', ~;
.

Transact-SQL :
,

;
,

. , .
.
tblStreet:
SELECT * FROM [Real EstateSQL].dbo.tblStreet

Real EstateSQL , SELECT .


, .
, , .

III. "-"

426

. , .
.
? , , ,
?
Transact-SQL :
SET QUOTED_IDENTIFIER {ON | OFF}

MS SQL Server Management Studio , .


:
SET QUOTED_IDENTIFIER ON
GO

QUOTED_IDENTIFIER, ON, MS
SQL Server :
.

,
;
-

.
QUOTED_IDENTIFIER, OFF, :
,

. ,
;
.

13.7.2.
, Transact-SQL,
, .
. . . Transact-SQL

13. " " MS SQL Server 2005

427

. 13.1
:
"", -

.
;
/* -

*/. "" .
13.1. Transact-SQL
/* */
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
GO
ALTER TRIGGER [T_tblFlats_UpTrig] -
ON [dbo].[tblFlats] FOR UPDATE, INSERT AS
SET NOCOUNT ON
Declare @SqFlat REAL

--

Declare @SqBal REAL

--

IF UPDATE /* */ (SQUAREFLAT)
OR UPDATE(DWELL)
BEGIN
SELECT @SqFlat =inserted.SQUAREFLAT,
@SqBal=inserted.BALCONY
FROM inserted
IF @SqFlat,1) < @SqBal
ROLLBACK TRANSACTION

END

13.7.3.
, . -

428

III. "-"

. Transact-SQL
: .
.
. .
:
DECLARE <_> <_>

@. .
. @Account :
DECLARE @Account int

,
:
DECLARE @LastName nvarchar(20),
@FirstName nvarchar(15),
@SecondName nvarchar(25)

. . : @@.
:
SET SELECT. SET , :
DECLARE @ModelCar nvarchar(15)
SET @ModelCar='Carina'

SELECT . @SqFlat SQUAREFLAT tblBuilding.


DECLARE @SqFlat real
SELECT @SqFlat = SUM(SQUAREFLAT) FROM tblBuilding

13.7.4.
MS SQL Server , ,
, , , , . .

13. " " MS SQL Server 2005

429

, () ( ).
, ,
. (. 13.3) , , .
13.3. Transact-SQL

- ()


: True ( ) False ( ). . 13.4.
13.4. Transact-SQL

>

>=

<

<=

<> !=

!<

!>

AND, OR NOT (. 13.5).

III. "-"

430

13.5. Transact-SQL

AND

""
()

True AND False

False

True AND True

True

""
()

False OR False

False

True OR False

True

NOT False

True

NOT True

False

OR

NOT

Transact-SQL
. :
1. MS SQL Server Management Studio,

.
2. Standard -

New Query.
3.

.
Object Explorer ( ) New Query
( ).
4. (. . 13.4).

. , .
. , ! Execute (), ,
.
: Results () Messages ().
AND, OR NOT Transact-SQL 7 .
ALL .

, True.
, .
IF '' <> ALL (SELECT FAMILY FROM tblAccount)
PRINT ' '

13. " " MS SQL Server 2005

431

ELSE
PRINT ' '

BETWEEN True, -

, False, . , 1970
1980. ,
BETWEEN True.
SELECT STREET,HOUSE,YEAR FROM tblBuilding
WHERE YEAR BETWEEN 1970 AND 1980

------
14

57

1977

14

58

1971

16

17

13

!Execute ------

1980
1970

:
SELECT STREET,HOUSE,YEAR FROM tblBuilding
WHERE YEAR >= 1970 AND YEAR<=1980

ANY ( SOME)

. ,
True. , .
IF '' = ANY (SELECT FAMILY FROM tblAccount)
PRINT ' '
ELSE
PRINT ' '

EXIST True, ,

. , .
False
IF

EXIST (SELECT * FROM tblAccount WHERE FAMILY='')


PRINT ' '

ELSE
PRINT ' '

III. "-"

432

EXIST, ,
, ANY SOME
.

IN . -

,
True. ,
.
IF '' IN (SELECT FAMILY FROM tblAccount)
PRINT ' '
ELSE
PRINT ' '

IN ANY, ,
. . , , :
IF '' IN ('','')
PRINT ' '
ELSE
PRINT ' '
------

!Execute ------

LIKE True, , -

False.
, "".
SELECT FAMILY,NAME,SECOND FROM tblAccount
WHERE FAMILY LIKE '%'

13. " " MS SQL Server 2005

433

,
, "".
SELECT FAMILY,NAME,SECOND FROM tblAccount
WHERE FAMILY LIKE '___%'
------

!Execute ------

13.7.5.
Transact-SQL . :
1. MS SQL Server Management Studio,

.
2. Standard -

New Query.
3.

.
Object Explorer New Query ( ).
4. (. .13.4).

. , .
. , ! Execute (), ,
.
: Results () Messages ().

434

III. "-"

, Transact-SQL
. :
BEGIN
<1>
<2>
...
END


. .
: tblBuilding tblStreet.
DECLARE @CountRecordALL smallint

DECLARE @CountRecordPart smallint --


BEGIN
SELECT @CountRecordALL=COUNT(*)FROM tblBuilding
SELECT @CountRecordPart=COUNT(*)FROM tblStreet
SET @CountRecordALL=@CountRecordALL+@CountRecordPart
PRINT @CountRecordALL
END

------

!Execute ------

1231

.
.
Transact-SQL IF...ELSE.
THEN, IF ELSE .
:
IF <>
<1>
ELSE
<2>

ELSE , , .
- , BEGIN...END.

13. " " MS SQL Server 2005

435

DECLARE @CountBuild smallint,@CountFlat smallint


SELECT @CountBuild=COUNT(*)FROM tblAccount
IF (@CountBuild<20000 AND MONTH(GETDATE())=6)
--
BEGIN
PRINT ' '
SELECT @CountFlat=COUNT(*)FROM tblFlats
IF @CountFlat BETWEEN 2000 AND 2200
PRINT ' , '
END
ELSE
PRINT ' '

------

!Execute ------

,
CASE...END. :
CASE <_>
WHEN <1> THEN <_>
WHEN <2> THEN <_>
...
ELSE <_>
END

, Transact-SQL .
(_). CASE, .
CASE...END - Transact-SQL. , , PRINT, ,
. . .
. , WHEN, ,
-, THEN. , ,
ELSE.

III. "-"

436


, WHEN, , .
DECLARE @Rouble char(25)
SET @Rouble='6 '
PRINT
CASE @Rouble
WHEN '1 ' THEN ' '
WHEN '2 ' THEN ' '
WHEN '5 ' THEN ' '
ELSE ' '
END

------

!Execute ------

CASE...END SQL-. , Transact-SQL.


, , .
SELECT

STREET,NAME,PRIZNAK =

CASE SIGN
WHEN '' THEN '.'
WHEN '' THEN '.'
WHEN '' THEN '.'
WHEN '' THEN '.'
WHEN '' THEN '.'
ELSE ''
END
FROM tblStreet
ORDER BY NAME

------

!Execute ------

STREET NAME

SIGN

PRIZNAK

[]

[]

13. " " MS SQL Server 2005


3

10

11

12

13

14

15

437

Transact-SQL : WHILE...CONTINUE.
. . ,
: ,
, Transact-SQL
. :
WHILE <>
{ | }
[BREAK]
{ | }
[CONTINUE]

.
BREAK. 1 5.
DECLARE @Number tinyint
PRINT '

'

SET @Number = 1
WHILE @Number<=5
BEGIN
PRINT LTRIM(STR(@Number)+STR(@Number*@Number)
+ STR(@Number*@Number*@Number))
SET @Number=@Number+1
END

III. "-"

438
------

1
2
3
4
5

!Execute ------

1
4
9
16
25

1
8
27
64
125

Transact-SQL.
! Execute
() . ,
. , ,
GO.

Transact-SQL MS SQL Server 2005 Microsoft . TRY...CATCH. :


BEGIN TRY
-- ,
END TRY
BEGIN CATCH
-- ,
END CATCH

13.8. MS SQL Server 2005


Microsoft SQL Server 2005 . Microsoft Access. MS SQL Server . 13.6.
13.6. SQL Server 2005

Abs()

Abs(-345.6)

345.6

13. " " MS SQL Server 2005

439

13.6 ()

Acos()

Acos(0.5)

1.0471976

Asin()

Asin(0.5)

0.5235988

Atan()

Atan(1)

0.7853982

Atn2()

,
,
,

Atn2(3,3)

0.7853982

Ceiling()

Ceiling(-15.2)

15

Ceiling (13.6)

14

Cos()

Cos(1)

0.5403023

Cot()

Cot(1)

0.6420926

Degrees()

Degrees(1.0)

57.29578

Exp()

Exp(1)

2.7182818

Floor()


(. )

Floor(-15.2)

16

Floor(13.6)

13

, ,
, 1. 0

IsNumeric(1.2)

IsNumeric

440

III. "-"

13.6 ()

Log()

Log(10)

2.302585

Log10()

Log10(100)

2.0

Pi()

Pi()

3.1415926

Power()

Power(3,3)

27

Radians()

Radians(90.0)

1.5707963

Rand()


0 1

Rand()

0.8529751
()

Sign()

1 , 0 , 1

Sign(-10.1)

Sign(0)

Sign(10.1)

Sin()

Sin(1)

0.8414710

Sqrt()

Sqrt(2)

1.4142136

Square()

Square(1.2)

1.44

Tan()

Tan(1)

1.5574077

. 13.7.
13.7. MS SQL Server 2005

GetDate()

GetDate()

12.03.2007
09:33:21.153

13. " " MS SQL Server 2005

441

13.7 ()

Day()

Day(GetDate())

12

Month()

Month(GetDate))

Char()

,

ASCII

Char(37)

% ()

Year()

Year(GetDate())

2007

Len()

Len('')

Lower()

Lower('aSD')

asd

Upper()

Upper('aSD')

ASD

Replicate()

Replicate('Ado',2)

AdoAdo

Substring()


.
,

Substring
('abcdef',2,3)

bcd

Rtrim()

Rtrim('abcd ')

abcd

Ltrim()

Ltrim(' abcd')

abcd

Reverse()

Reverse('')

Str()

Str(1234.56)

1234.56

III. "-"

442

13.9.
, , . MS SQL Server 2005 . MS Access, MS SQL Server
.
, , . . . ,
. ,
.

13.9.1.
, . :
1. SQL Server Management Studio.
2. Connect to Server ( ). -

, , . Connect ().
3. Object Explorer Databases

( ), .
4. Tables ().

Indexes. .
5. New Index ... ( ). -

New Index. Table name ( ) , , (. 13.6).


6. Index name ( ) . -

Index type ( ),
, .
Unique ().
7. , ,

Add (). Select Columns from ....


8. , ,

OK.

13. " " MS SQL Server 2005

443

9. Select Columns from ... ,

New Index ( ).
10. Sort Order.

. Ascending ( ) Descending ( ). OK.

. 13.6.
Account tblFlats

444

III. "-"

13.9.2.
, . (. 13.7):
1. SQL Server Management Studio.
2. Connect to Server. -

, , . Connect ().
3. Object Explorer Databases

( ), .

. 13.7. tblBuilding

13. " " MS SQL Server 2005

445

4. Tables (). -

.
5. . Modify ().

.
6. Manage Indexes and Keys.

. Indexes/Keys.
, .
7. , , General

() Columns ().
Index Columns.
8. Indexes/Keys Add () De-

lete () .

13.9.3.
,
.
. ,
, NULL. MS SQL Server 2005
(Unique) .
. :
1. SQL Server Management Studio.
2. Connect to Server. , -

, . Connect
().
3. Object Explorer Databases

( ), .
4. Tables (). -

.
5. . Modify (-

). .
6. Allow Nulls ( )

, .

446

III. "-"

7. , -

. .
8. , , -

<Ctrl>,
.
9. Set Primary Key ( -

), .
.
, .

13.10.

. . ,
1 9 .
District tblDistrict,
:
1. SQL Server Management Studio.
2. Connect to Server. -

, , . Connect ().
3. Object Explorer Databases

( ), .
4. Tables (). -

.
5. Constraint.

. New Constraint ...


( ). Check Constraints
(. 13.8).
6. Name () .

13. " " MS SQL Server 2005

447

7. Expression (-

). . . Check Constraint Expression.


8. OK.
9. Description .
10. Close ().

. 13.8. tblDistrict


, (19),
(. 13.9).
, , .
CHECK ,
-.
. 13.14.

448

III. "-"

. 13.9.

13.11.


.
.
.
, .
.
( ) ( ):
;
,

,
;
-

13.11.1. "--"
tblDictrict () tblBuilding (). , "--", . .
. ,
. :
1.

SQL Server Management Studio.

13. " " MS SQL Server 2005

449

2. Connect to Server. -

, , . Connect ().
3. Object Explorer Data-

bases ( ), .
4. Database Diagrams ( ).

. . .
,
.
5. .

.
6. tblDictrict tblBuilding , .
7.


tblDictrict. DISTRICT. . (
DblClick). . .

8. , -

DISTRICT tblBuilding, . : Foreign Key Relationship Tables and Columns (. 13.10).


9. Tables and Columns Relationship name -

tblBuilding. , : FK_tblBuilding_tblDistrict.
"FK" Foreign Key ( ),
tblBuilding ,
tblDictrict .
10. "" , -

. OK
Tables and Columns.
11. Foreign Key Relationship. -

Enforce Foreign Key Constraint Yes .


.

III. "-"

450

Delete Rule ( ) Update Rule ( ). Cascade (), tblDictrict


tblBuilding.
12. -

, Foreign Key Relationship:

Enforce Foreign Key Constraint Yes;

Delete Rule No Action;

Update Rule No Action.

. 13.10. "--" tblDictrict


tblBuilding

, , DRI,
. , ,
.

13. " " MS SQL Server 2005

451

tblFlats ()
tblOwners ().
tblFlats : STREET, HOUSE FLAT.
tblOwners .
:
1. SQL Server Management Studio.
2. Connect to Server. , -

, . Connect
().
3. Object Explorer Databases

( ), .
4. Database Diagrams ( ).

. .
. , .
5. .

.
6. tblFlats tblOwners , .

. 13.11. "--" tblFlats


tblOwners

III. "-"

452

7. ,

STREET tblFlats. . <Ctrl> , ,


HOUSE, FLAT. <Ctrl>.
. .
8. ,

, , ,
STREET tblOwners. . : Foreign Key Relationship Tables and Columns (. 13.11).
9. Tables and Columns ( ) Relationship

name tblOwners.
, :
FK_tblOwners_tblFlats. "FK" Foreign Key
( ), tblOwners ,
tblFlats .
10. "" ,

Tables and Columns Primary Key Table (


) tblFlats : STREET+HOUSE+FLAT, Foreign Key Table (
) tblOwners STREET .
11. -.

: HOUSE FLAT. OK Tables and Columns.


tblOwners

12. Foreign Key Relationship. -

Enforce Foreign Key Constraint Yes .


.
Delete Rule Update Rule. Cascade (),
tblFlats tblOwners.

13.11.2. "--"
tblFlats ()
tblAccount ( ).

13. " " MS SQL Server 2005

453

, . :
1. SQL Server Management Studio.
2. Connect to Server ( ).

, , .
Connect ().
3. Object Explorer Data-

bases ( ), .
4. Tables (). tblFlats.

Indexes ().
.
5. New Index... ( ). -

New Index. Table name ,


, : tblFlats.
6. Index Name : ACCOUNT.
7. Unique.
8. ACCOUNT, ,

Add. Select Columns from ....


OK.
9. Select Columns from... , ACCOUNT -

New Index.
10. Sort Order.

. Ascending ( ).
OK.
11. Database Diagrams. -

. .
.
, .
12. .

.
13. tblAccount tblFlats , .
14.


tblAccount. ACCOUNT.

454

III. "-"

. ( DblClick).
. .
15. , -

ACCOUNT tblFlats,
. : Foreign Key Relationship Tables
and Columns.
16. Tables and Columns Relationship name -

tblFlats. ,
: FK_tblFlats_tblAccount.
"FK" Foreign Key ( ),
tblFlats , tblAccount .
17. "" , -

. OK
Tables and Columns.
18. Foreign Key Relationship. -

Enforce Foreign Key Constraint Yes .


.
Delete Rule Update Rule. Cascade,
tblAccount
tblFlats.

13.12.
() ,
.
, . SQL-, . , ,
, .

13. " " MS SQL Server 2005

455

MS Access . ,
, . , . , "" . SELECT,
.
, ,
, ,
:
;

FROM;

UPDATE INSERT, -

, , ;
GROUP
DISTINCT, UNION

TOP,

BY,
(SUM, COUNT, MAX

.).
MS SQL Server 2005
, Microsoft SQL Server Management Studio.
.

, .
.
,
Real EstateSQL.
, , , , .
MS SQL Server.
:
1. SQL Server Management Studio.

456

III. "-"

2. Connect to Server ( ).

, , .
Connect ().
3. Object Explorer Databases

( ), .
4. Views. -

. New View....
5.

Add Table.
: Tables, Views, Functions Synonyms.

. 13.12. (View)
Microsoft SQL Server Management Studio

13. " " MS SQL Server 2005

457

6. Transact-SQL

: tblBuilding, tblStreet, tblDistrict tblWall.


Add.
7. Add Table.


(. 13.12).
8.

. Table
, Column .
9. ,

, AREA Filter
=''.
10. -

Transact-SQL. 13.2.
13.2. AREA Transact-SQL
SELECT dbo.tblStreet.NAME,dbo.tblStreet.SIGN,
dbo.tblBuilding.HOUSE,dbo.tblDistrict.AREA,
dbo.tblBuilding.LAND,dbo.tblBuilding.YEAR,
dbo.tblBuilding.WEAR,dbo.tblWall.WALL,
dbo.tblBuilding.SQUARE
FROM dbo.tblWall INNER JOIN
dbo.tblDistrict INNER JOIN
dbo.tblStreet INNER JOIN
dbo.tblBuilding ON
dbo.tblStreet.STREET = dbo.tblBuilding.STREET ON
dbo.tblDistrict.DISTRICT = dbo.tblBuilding.DISTRICT
ON dbo.tblWall.MATERIAL = dbo.tblBuilding.MATERIAL
WHERE (dbo.tblDistrict.AREA = '')

,
. . .

458

III. "-"

13.13.
Transact-SQL, . ,
, - .
. , .
, . .
, , . "",
, , .
, . MS SQL Server 2005
.
,
, "" . .
.
.

Transact-SQL. :
CREATE { PROC | PROCEDURE } [schema_name.] procedure_name
[ { @parameter [ type_schema_name. ] data_type }
[ VARYING ] [ = default ] [ OUTPUT ]
] [ ,...n ]
[ WITH
{ ENCRYPTION | RECOMPILE | EXECUTE AS Clause}]
[ FOR REPLICATION ]
AS { <sql_statement> [;][ ...n ] | <method_specifier> }
[;]

:
schema_name , ;

13. " " MS SQL Server 2005

459

procedure_name

.
(sp_),
(##);

@parameter , -

. .
2100;
type_schema_name , ;
data_type ;
VARYING OUTPUT
cursor;

default ;
ENCRYPTION ;
RECOMPILE -

;
FOR REPLICATION ;
AS ;
sql_statement . -

, BEGIN...END.
, ,
.
: .
:
1. SQL Server Management Studio.
2. Connect to Server ( ).

, , .
Connect ().
3. Object Explorer Databases,

.
4. Programmability.
5. Stored Procedures (-

). .
New Stored Procedure ... ( ). .

460

III. "-"

6. -

<Ctrl>+<Shift>+<M>. Specify
Values for Template Parameters. , ,
.
7. , 13.3.
8. ! Execute () . -

, ,
.
9. Stored Procedures. -

. Refresh ().
10. Object Explorer

Stored Procedures.
13.3. Citizens
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go
-- =============================================
-- Author:

-- Create date: 01.05.2007


-- Description:
-- =============================================
CREATE PROCEDURE [dbo].[Citizens]
-- Add the parameters for the stored procedure here
@StreetSQL smallint,
@HouseSQL smallint
AS
BEGIN
SELECT FAMILY,NAME,SECOND
FROM dbo.tblOwners
WHERE STREET=@StreetSQL AND HOUSE=@HouseSQL
END

Citizens
New Query, . . :
EXECUTE Citizens @StreetSQL=2, @HouseSQL=10

13. " " MS SQL Server 2005

461

EXECUTE , @StreetSQL=2 ,
, @HouseSQL=10 .
! Execute .
Results :

...

Messages , 143 :
(143 row(s) affected)

13.14.
Transact-SQL ,
(, ).
.
. Transact-SQL, . , , , ,
. . :
CREATE TRIGGER [ schema_name. ]trigger_name
ON { table | view }
[ WITH [ ENCRYPTION ][ EXECUTE AS Clause ][ ,...n ] ]
{ FOR | AFTER | INSTEAD OF }
{ [ INSERT ] [ , ] [ UPDATE ] [ , ] [ DELETE ] }
[ WITH APPEND ]
[ NOT FOR REPLICATION ]
AS { <sql_statement> [;][ ...n ] | <method_specifier> }
[;]

III. "-"

462

:
schema_name , ;
trigger_name ;
{table | view} , -

;
ENCRYPTION ;
EXECUTE AS ;
FOR , ;
AFTER ( );
INSTEAD OF , -

;
INSERT, UPDATE, DELETE ,

;
WITH APPEND

MS SQL Server;
NOT FOR REPLICATION ,

;
AS ;
sql_statement . ,

BEGIN...END.
, tblAccount. :
tblFlats (
ACCOUNT)

,
(tblAccount);

tblAccount. ,
, , , ,
(. 13.8).

13. " " MS SQL Server 2005

463

13.8. ,
tblAccount ,

UserName

nvarchar(20)

MS SQL Server 2005

[DateTime]

datetime

HostName

nvarchar(20)

ClientName

nvarchar(128)

:
1. SQL Server Management Studio.
2. Connect to Server ( ).

, , .
Connect ().
3. Object Explorer Data-

bases ( ), .
4. Tables ().
tblAccount

5. Triggers ().

. New Trigger... ( ). .
6. -

<Ctrl>+<Shift>+<M>. Specify
Values for Template Parameters. , ,
.
7. 13.4.
8. ! Execute () . -

, ,
.
9. Triggers. -

. Refresh ().
10. Object Explorer Triggers.

III. "-"

464

13.4. T_tblAccount_UTrig
CREATE TRIGGER T_tblAccount_UTrig
ON dbo.tblAccount FOR UPDATE AS
SET NOCOUNT ON
/* * 'tblFlats' */
IF UPDATE(ACCOUNT)
BEGIN
UPDATE tblFlats
SET tblFlats.ACCOUNT = inserted.ACCOUNT
FROM tblFlats, deleted, inserted
WHERE deleted.ACCOUNT = tblFlats.ACCOUNT
END
/* * */
UPDATE tblAccount SET
UserName=suser_sname(),--
[DateTime]=getdate(),

--

HostName=host_name(),

-- ,

ClientName=app_name()

--

FROM inserted JOIN tblAccount


ON inserted.ACCOUNT=tblAccount.ACCOUNT

. ,
MS Access 2007
tblAccount. (. 13.13).

. 13.13. T_tblAccount_UTrig

, tblAccount,
: inserted deleted.

13. " " MS SQL Server 2005

465

. .
?
INSERT. inserted -

.
. deleted
.
UPDATE. deleted

, , .
inserted . .
DELETE. deleted ,

.
. inserted
.

14


Microsoft Access
12 Access- "". MS Access 2007
. Real EstateSQL MS SQL Server 2005, , ,
, ( Real Estate.accdb), MS Access Real EstateCS.adp. Microsoft Access 2007 OLE DB (. 14.1).

. 14.1. SQL-
MS Access

14.1.


"-", .

14. Microsoft Access

467

Real Estate, .
: " ,
?" !

95% , .
- .

14.2.

,
RTF- (Real Estate.RTF
- ).
. , MS Access 2007
SQL Server?

14.2.1.
. Real Estate : ": tblUser.
".
, . , . tblUser .
:
'tblUser'
156: Incorrect syntax near the keyword 'File'.

. File, , , . .
Transact-SQL File. .
FilePhoto .
. MS SQL
Server 2005.

III. "-"

468

14.2.2.

MS Access SQL Server.
. ACE
SQL Server, ,
.
. CHECK. MS SQL Server 2005
. 14.2. tblFlats,
, SQL Server
:
[SQUAREFLAT]=[DWELL]+[BRANCH]+[BALCONY]
.

,
Flats ( 14.1).

. 14.2. Check
" 1 9"

14. Microsoft Access

469

14.1.
Private Sub Form_BeforeUpdate(Cancel As Integer)
If Round(txtSQUAREFLAT.Value, 1) <> _
Round(txtDWELL.Value + txtBRANCH.Value + _
txtBALCONY.Value, 1) Then
'
MsgBox " .", _
vbOKOnly + vbExclamation, ""
'
txtSQUAREFLAT.SetFocus
'
Cancel = 1
End If
End Sub

Form_BeforeUpdate
( Round()).
"" .
:
[SQUAREFLAT]=[DWELL]+[BRANCH]+[BALCONY]


(), . , Transact-SQL.
14.2.
14.2. T_tblFlats_UTrig1,

CREATE TRIGGER T_tblFlats_UTrig1
ON dbo.tblFlats FOR UPDATE, INSERT AS
SET NOCOUNT ON
--
Declare @SqFlat DECIMAL(7,1)

--

Declare @SqDwell DECIMAL(7,1) --


Declare @SqBranch DECIMAL(7,1)--
Declare @SqBal DECIMAL(7,1)

--

III. "-"

470

IF UPDATE(SQUAREFLAT) OR UPDATE(DWELL)
OR UPDATE(BRANCH) OR UPDATE(BALCONY)
BEGIN
SELECT @SqFlat =inserted.SQUAREFLAT,
@SqDwell=inserted.DWELL,
@SqBranch=inserted.BRANCH,
@SqBal=inserted.BALCONY
FROM inserted
IF @SqFlat <> (@SqDwell+@SqBranch+@SqBal)
BEGIN
RAISERROR ('
',11,1)
-
ROLLBACK TRANSACTION
END
END

: @SqFlat,
@SqDwell, @SqBranch @SqBal, . :
DECIMAL(7,1). ,
tblFlats, MS SQL : inserted.
tblFlats, : REAL. DECIMAL ( ), = ()
ROUND() .

.
RAISERROR, :
RAISERROR ( { msg_id | msg_str | @local_variable }
{ , severity, state }
[ , argument [ ,...n ] ] )
[ WITH option [ ,...n ] ]

14. Microsoft Access

471

:
msg_id . , -

, sys.messages sp_addmessage,
50000, ;
msg_str 2047 ;
@local_variable

char varchar;
severity .

0 18. 2025 Transact-SQL;


state . 1127. -

;
argument

. 20.
: tinyint, smallint, int, char, varchar, nchar,
nvarchar, binary, varbinary. ;
option :

LOG

NOWAIT

SETERROR

;
;

msg_id ( ) @@ERROR 50000,


.

,
, 50000,
(New Query) :
sp_addmessage 50001,11, '
'

50001 ; 11 .
RAISERROR :
RAISERROR (50001,11,1)

( ),
sys.messages, SELECT:

472

III. "-"

SELECT * FROM sys.messages

sp_dropmessage .
. 14.3 , , Microsoft SQL
Server Management Studio. :
"Query completed with errors". ,
, ,
RAISERROR.

. 14.3. RAISERROR sys.messages

14. Microsoft Access

473

MS SQL Server , sys.messages, . , .


.

14.2.3.
,
,
. . . 14.4 , tblBuilding.
, .

. 14.4. ,
tblBuilding ()

MS SQL Server 2005 , .

III. "-"

474

"PK" ( Primary Key), "FK" (Foreign Key). , ,


. , "" , , , ,
. MS SQL Server ,
MS Access.
tblBuilding, , .
tblStreettblBuilding

(tblDistricttblBuilding,
tblWalltblBuilding) MS Access
(DISTRICT, MATERIAL STREET), MS Access. ""
.

, . . .

14.2.4.
MS Access 2007 MS Access 2007 Real Estate . . ,
,
,
( ).
,
( ). MS SQL Server?
tblWall ( ) . ( "") , . .
tblBuilding . Material
! ? .
14.3.

14. Microsoft Access

475

14.3. T_tblWall_UTrig
tblBuilding tblWall
CREATE TRIGGER T_tblWall_UTrig ON [tblWall] FOR UPDATE AS
SET NOCOUNT ON
/* * 'tblBuilding' */
IF UPDATE(MATERIAL)
BEGIN
UPDATE tblBuilding
SET tblBuilding.MATERIAL = inserted.MATERIAL
FROM tblBuilding, deleted, inserted
WHERE deleted.MATERIAL = tblBuilding.MATERIAL
END

MS SQL.

. , MS SQL Server .
, .

MS Access , , DRI MS SQL Server, .

14.2.5.
, ? , ,
, Real Estate , .

, , .
SQL Server , , ,
, , ,

476

III. "-"

.
.
MS
SQL Server 2005? Object
Explorer (. 14.5). Views :
dbo.qwrArea.

. 14.5. MS Access 2007 qwrArea


MS SQL Server 2005 dbo.qwrArea,

.
. Modify. dbo.qwrArea
. . . 14.5
. .
, , , .

14. Microsoft Access

477

, . , ( 14.4).
14.4. dbo.qwrArea Transact-SQL
SELECT dbo.tblStreet.NAME,dbo.tblStreet.SIGN,dbo.tblBuilding.HOUSE,
dbo.tblDistrict.AREA,dbo.tblBuilding.LAND,
dbo.tblBuilding.YEAR,
dbo.tblBuilding.WEAR, dbo.tblWall.WALL,
dbo.tblBuilding.SQUARE
FROM

dbo.tblWall INNER JOIN


dbo.tblDistrict INNER JOIN
dbo.tblStreet INNER JOIN
dbo.tblBuilding ON dbo.tblStreet.STREET =
dbo.tblBuilding.STREET ON dbo.tblDistrict.DISTRICT =
dbo.tblBuilding.DISTRICT ON
dbo.tblWall.MATERIAL = dbo.tblBuilding.MATERIAL

WHERE (dbo.tblDistrict.AREA = '')

MS Access SQL Transact-SQL


, . MS Access ( 14.5). dbo (data base owner).
MS SQL Server 2005, .
14.5. qwrArea MS Access SQL
SELECT tblStreet.NAME, tblStreet.SIGN, tblBuilding.HOUSE,
tblDistrict.AREA, tblBuilding.LAND,
tblBuilding.YEAR,
tblBuilding.WEAR, tblWall.WALL,
tblBuilding.SQUARE
FROM tblWall INNER JOIN
(tblDistrict INNER JOIN
(tblStreet INNER JOIN tblBuilding ON
tblStreet.STREET=tblBuilding.STREET) ON

478

III. "-"
tblDistrict.DISTRICT=tblBuilding.DISTRICT) ON
tblWall.MATERIAL=tblBuilding.MATERIAL

WHERE (((tblDistrict.AREA)=""));

qwrFlats, ,
, Object Explorer
Programmability Functions.
dbo.qwrFlats,
Table-valued Functions (. 14.6).
:
@Forms_Building_Street1 ( );
@Forms_Building_House2 ( ),

tblFlats tblAccount ( 14.6).

. 14.6. MS Access 2007 qwrFlats,


dbo.qwrFlats MS SQL Server 2005

14. Microsoft Access

479

14.6. dbo.qwrFlats
ALTER FUNCTION [dbo].[qwrFlats]
(@Forms_Building_Street1 varchar (255),
@Forms_Building_House2 varchar (255))
RETURNS TABLE
AS
RETURN ( SELECT dbo.tblFlats.STREET,dbo.tblFlats.HOUSE,
dbo.tblFlats.FLAT,dbo.tblFlats.STOREY,dbo.tblFlats.ROOMS,
dbo.tblFlats.SQUAREFLAT,
dbo.tblFlats.DWELL, dbo.tblFlats.BRANCH,
dbo.tblFlats.BALCONY, dbo.tblFlats.HEIGHT,
dbo.tblAccount.ACCOUNT, dbo.tblAccount.FAMILY,
dbo.tblAccount.NAME, dbo.tblAccount.SECOND
FROM dbo.tblAccount INNER JOIN
dbo.tblFlats ON dbo.tblAccount.ACCOUNT =
dbo.tblFlats.ACCOUNT
WHERE (dbo.tblFlats.STREET = @Forms_Building_Street1) AND
(dbo.tblFlats.HOUSE = @Forms_Building_House2) )


- , varchar(255), " ", - : smallint.
dbo.qwrFlats Table-valued Functions
New Query,
. :
DECLARE @sqlStreet smallint,
@sqlHouse smallint
SET @sqlStreet=2
SET @sqlHouse=10
SELECT * FROM dbo.qwrFlats(@sqlStreet,@sqlHouse)

, EXECUTE, SELECT.
, :
SELECT * FROM dbo.qwrFlats(2,10)

480

III. "-"

! Execute ()
(. 14.7). dbo.qwrFlats
67 , .

. 14.7.
dbo.qwrFlats

, Microsoft MS Access 2007 MS


SQL Server 2005. qwrFlats MS
Access 2003 SQL Server 2000 .
MS
SQL Server 2005. tblUser -
File, ( ) Transact-SQL,
tblFlats. MS Access MS SQL Server
. . , .
?

14. Microsoft Access

481

14.3. MS Access
Real EstateCS.adp, , ( ) Real Estate.accdb (. 14.8).

. 14.8. Building MS Access

. 14.9.

482

III. "-"

Building .
MS Access 2007. :
.


, .
, , (. 14.9).

.
.
.

. 14.10. MS Access
MS SQL Server 2005

14. Microsoft Access

483

MS Access Real EstateCS.adp


Real EstateSQL, Master.
, MS Access , Real
EstateCS.adp :
1. Microsoft Access 2007 Office.

Office.
2. .

.
3. . .

(. 14.10).
4. -

OK.

14.4.

Real EstateCS.adp, . , ,
, . .
.
1. Login ( ) , VBA 91 (. 14.11).
( 14.7):
NameBase = CurrentDb.NAME
14.7. CurrentPath()
Public Function CurrentPath() As String
'
'
Dim NameBase As String

484

III. "-"

Dim NameBaseShort As String


Dim CountLetter As Integer
' ,
NameBase = CurrentDb.NAME
'
' Dir() - VBA
NameBaseShort = Dir(NameBase)
CountLetter = Len(NameBase) - Len(NameBaseShort) - 1
' CountLetter
' Left() - VBA
CurrentPath = Left(NameBase, CountLetter)
End Function

. 14.11. ,
CurrentDb.Name

CurrentDb.NAME ( ) MS
Access. . , Real
Estate.accdb ?
.
, Real Estate.accdb, Real Estate.adp. : , CurrentPath() CurrentProject.Path, .
, ( 14.8).

14. Microsoft Access

485

14.8.
Public Function CurrentPath() As String
'
' , ADP
CurrentPath = CurrentProject.Path
End Function

2. Login (
) (. 14.12). c 13, :
ChangePassword = [Forms]![Login]![ComboBox].Column(7)

. 14.12. , Boolean (VBA),


Logical ( 0 1 Access) Bit ( 0 1 MS SQL Server)

ChangePassword :
Public ChangePassword As Boolean

ComboBox Login
tblUser ( Access02), MS Access . VBA . ?
VBA MS Access , VBA SQL Server 2005 ?
tblUser, . Access02
Bit MS SQL Server. VBA 1 ()

III. "-"

486
True?

, VBA True 1 ( ),
MS Access. , , :
If [Forms]![Login]![ComboBox].Column(7) = 0 Then
ChangePassword = False
Else
ChangePassword = True
End If

3. PageBuilding (
) (. 14.13). , :
SQLText = "SELECT tblBuilding.Street, " & _
"tblStreet.Name AS , " & _
"tblStreet.Sign AS , " & _
"tblBuilding.House AS , tblDistrict.AREA AS , " & _
"tblBuilding.Land AS , tblBuilding.Year AS " & _
"FROM tblStreet, tblBuilding, tblDistrict " & _
"WHERE

tblStreet.Street = tblBuilding.Street " & _

"AND tblDistrict.District = tblBuilding.District "

. 14.13. , , MS SQL Server .


SQL- STREET

Street tblBuilding VBA


? ,
tblBuilding Real Estate MS SQL Server Master !
STREET. (

14. Microsoft Access

487

), .
Street, :
SQLText = "SELECT tblBuilding.STREET, " & _
"tblStreet.NAME AS , " & _
"tblStreet.SIGN AS , " & _
"tblBuilding.HOUSE AS , tblDistrict.AREA AS , " & _
"tblBuilding.LAND AS , tblBuilding.YEAR AS " & _
"FROM tblStreet, tblBuilding, tblDistrict " & _
"WHERE

tblStreet.STREET = tblBuilding.STREET " & _

"AND tblDistrict.DISTRICT = tblBuilding.DISTRICT "

4. PageBuilding (
) (. 14.14). , CountQuery() Open,
Real Estate ( 14.9).

. 14.14. , , MS Access
,

14.9. CountQuery(),
,
Public Function CountQuery(SQLText) As Integer
'
' SQLText -

III. "-"

488

Dim CountSelectSQL As Integer

'

'
Dim Connect As ADODB.Connection
' Connect - , ""
' ADO
Dim rsCount As ADODB.Recordset
' rsCount - ,
'
Set Connect = New ADODB.Connection
' MS Access 2007 (.accdb)
With Connect
.ConnectionString = _
"Provider=Microsoft.ACE.OLEDB.12.0;" & _
"Data Source=" & CurrentPath() & "\Real Estate.accdb"
.Open
End With
...
End Function

, "" , Real EstateCS.adp. ,


, . MS SQL Server, MS Access!
:
With Connect
.ConnectionString = _
"Provider=SQLOLEDB;" & _
"Data Source=Master;" & _
"Database=Real EstateSQL;" & _
"Trusted_Connection=yes"
.Open
End With

14. Microsoft Access

489

MS Access.
MS SQL Server
, VBA, , AutoCAD.
, ADO. . :
Set Connect = CurrentProject.Connection

5. PageBuilding (
) ,
ListBox ,
CountQuery() , (. 14.15).
: " , : 30".
, .
RowSourceType Real Estate.accdb ( ):
ListBox.RowSourceType = "Table/Query"

Real EstateCS.adp (, ):
ListBox.RowSourceType = "Table/View/StoredProc"

. 14.15. , , MS Access
,

III. "-"

490

6. , PageBuilding ( ),
, , .
T_tblBuilding_DTrig
tblBuilding CommandDel_Click()
PageBuilding. , :
' : SqlUpdateErr
On Error GoTo SqlUpdateErr
...
SqlUpdateErr:
If Err.NUMBER = 2501 Then
MsgBox " .", _
vbOKOnly + vbExclamation, ""
End If

accdb-,
"Run-time error"
(. . 8.6), ""
2501. ,
CommandDel_Click() . , ! :
SqlUpdateErr:
Select Case Err.Number
Case 2501
'
MsgBox " .", _
vbOKOnly + vbExclamation, ""
Case 44445
'
' T_tblBuilding_DTrig
MsgBox " . !", _
vbOKOnly + vbExclamation, ""
Case Else
'
MsgBox Err.Description
End Select

14. Microsoft Access

491

7. PassWord ( ) (. 14.16). , :
SELECT tblUser.LastName, tblUser.FirstName,
tblUser.SecondName, tblUser.Post,
tblUser.PassWord, tblUser.Date_up,
User.Time_up
FROM [tblUser] WHERE
(((tblUser.LastName)=GetValueSQL()));

PassWord.
,
GetValueSQL(), 8.9.

. 14.16. , , SELECT

GetValueSQL()

, MS SQL- . MS
SQL Server ( FAMILY). .
,
, 14.10.

III. "-"

492

14.10. PassWord
Private Sub Form_Load()
Me.RecordSource = "SELECT tblUser.LastName, tblUser.FirstName, " & _
"tblUser.SecondName, tblUser.Post, tblUser.PassWord, " & _
"tblUser.Date_up, tblUser.Time_up " & _
"FROM tblUser " & _
"WHERE tblUser.LastName = '" & FAMILY & "'"
End Sub

8. PassWord ( ) (. 14.17). , :
TextSQL = "UPDATE tblUser " & _
"SET tblUser.PassWord = '" & NewPasswordOne & "'," & _
"tblUser.Date_up=Date(),tblUser.Time_up=Time() " & _
"WHERE tblUser.LastName = '" & FAMILY & "' "

. 14.17. , , UPDATE
Date() MS Access, GETDATE() MS SQL Server

VBA , MS SQL-. .
tblUser PassWord , , .

14. Microsoft Access

493

MS Access .
MS SQL Server,
, . "" -
, , . (. 13.4).
tblUser.
MS Access MS SQL Server.
. MS Access :
Date() Time(), MS SQL Server
GetDate(). MS Access Now(),
. ! / "" , Convert():
TextSQL = "UPDATE tblUser " & _
"SET tblUser.PassWord = '" & NewPasswordOne & "'," & _
"tblUser.Date_up=GETDATE()," & _
"tblUser.Time_up=CONVERT(CHAR(8),GETDATE(),14) " & _
"WHERE tblUser.LastName = '" & FAMILY & "' "

. ,
, accdb-.
. CurrentDb.Name, -

CurrentProject.Path CurrentProject.Connection.
RowSourceType = "Table/Query" .
MS Access .
. MS SQL Server, -

, .
.

, . VBA .
.

14.5.

MS Access 2007 MS SQL Server 2005. .

494

III. "-"

Flats, accdb-, , tblFlats


tblAccount. . : " ?
!". Owners, Flats, , tblOwners.
adp- Flats ,
qwrFlats (. 14.4) MS SQL Server 2005
Table-valued Functions. ,
. .
Flats, ,
Building (. 14.18). MS Access . , , Flats :
?

= Forms_Building_Street, ?

= Forms_Building_House

. 14.18. Flats

14. Microsoft Access

495

Flats.

. , :
@Forms_Building_Street=[Forms]![Building]![Street],
@Forms_Building_House=[Forms]![Building]![House]

qwrFlats
Building. Flats .

14.5.1.

Flats . ,
Building,
. . ? ! tblFlats
tblAccount , ( tblOwners) . , , , ,
, , ,
, .

14.5.2.

Flats adp- ?
qwrFlats (. 14.4), Access SQL-. , , .
Flats qwrFlats. , tblAccount, FROM
( 14.11).

III. "-"

496

14.11. qwrFlats
ALTER FUNCTION [dbo].[qwrFlats]
(@Forms_Building_Street smallint,
@Forms_Building_House smallint)
RETURNS TABLE
AS
RETURN (SELECT *
FROM dbo.tblFlats
WHERE (dbo.tblFlats.STREET = @Forms_Building_Street)
AND (dbo.tblFlats.HOUSE = @Forms_Building_House))

tblFlats
qwrFlats ( Flats) ,
.
, Flats, tblAccount, , ,
tblAccount. , - - .
, Flats. , Owners .
,
tblAccount.
.
.
:
1. Flats .
2. ,


. "" . .

3.

.
, . .

14. Microsoft Access

497

4. , , -

,
. . .
5. ,

. ""
. .
tblAccount.
6.

.
ACCOUNT.
7. . -

Real EstateCS. , SlaveAccount, .


8. .

. . 14.1.
14.1. SlaveAccount

9. , , -

ACCOUNT. <Delete>.
10. Flats

SlaveAccount. : ,
, , (. 14.19).
11. .

498

III. "-"

. , , . ""
-
<Ctrl>, - <Shift>.

. 14.19. Flats

Flats .
(. 14.20). tblFlats ( 14.12).
. ,
,

14. Microsoft Access

499

. .
.

. 14.20.

14.12. T_tblFlats_ITrig,
tblFlats.

ALTER TRIGGER T_tblFlats_ITrig
ON dbo.tblFlats FOR INSERT AS
SET NOCOUNT ON
/* * 'tblAccount' */
IF (SELECT COUNT(*) FROM inserted) !=
(SELECT COUNT(*) FROM tblAccount, inserted
WHERE (tblAccount.ACCOUNT = inserted.ACCOUNT))
BEGIN
RAISERROR 44447 '
.
"tblAccount".'
ROLLBACK TRANSACTION
END

, :
tblAccount

tblFlats;
tblAccount -

tbtFlats.
14.13 14.14 ,
tbtFlats .

III. "-"

500

14.13. T_tblFlats_DTrig,
tblFlats
CREATE TRIGGER [T_tblFlats_DTrig] ON [dbo].[tblFlats] FOR DELETE AS
SET NOCOUNT ON
/* * 'tblAccount' */
DELETE tblAccount
FROM deleted, tblAccount
WHERE deleted.ACCOUNT = tblAccount.ACCOUNT
14.14. T_tblFlats_UTrig,
tblFlats
CREATE TRIGGER [T_tblFlats_UTrig] ON [dbo].[tblFlats] FOR UPDATE AS
SET NOCOUNT ON
/* * 'tblAccount' */
IF UPDATE(ACCOUNT)
BEGIN
UPDATE tblAccount
SET tblAccount.ACCOUNT = inserted.ACCOUNT
FROM tblAccount, deleted, inserted
WHERE deleted.ACCOUNT = tblAccount.ACCOUNT
END

14.5.3.
Flats, I ,
, . , MS Access, .
.
, .

.
-

. "" ,
, .

14. Microsoft Access

501

, , .

.
Flats PageFlats, "", . MS Access 2007
accdb- adp-, , . :
1. MS Access 2007 ,

.
2. Flats.

.
3. . .
4. .

, . MS Access
.
5. . .
6. , -

(. 14.21). PageFlats OK.


7. Flats PageFlats

. 14.21. Flats


,
accdb adp,
.

502

III. "-"

PageFlats
:
1. -

<Ctrl>+<X>.
2. .

.
3. -

.
4. . ,

, .
. "" .

. 14.22. PageFlats

14. Microsoft Access

503

5. . .

Page1 Page2.
6. .

(. 14.22).
7. .
8. PageFrame.

PageFlats PageBuilding,
,
( 14.15).
14.15. PageBuilding
Private Sub CommandFlats_Click()
'
On Error GoTo Err_CommandFlats_Click
Dim stDocName As String
Dim stLinkCriteria As String
' ,
SelectAddressStreet = Me!ComboStreet.Value
'
SelectAddressHouse = Me!txtHOUSE.Value
stDocName = "PageFlats"
DoCmd.OpenForm stDocName, , , stLinkCriteria
Exit_CommandFlats_Click:
Exit Sub
Err_CommandFlats_Click:
MsgBox Err.Description
Resume Exit_CommandFlats_Click
End Sub

: SelectAddressStreet
SelectAddressHouse ( ), ModuleMain.
"" MS Access.
PageFlats
,
( 14.16).

504

III. "-"

14.16. PageFlats
Private Sub Form_Open(Cancel As Integer)
'
If Not CurrentProject.AllForms("PageBuilding").IsLoaded Then
MsgBox " ." _
& " PageBuilding!", _
vbOKOnly + vbExclamation, ""
Cancel = 1
End If
End Sub

,
PageFlats. , ,
, (. 14.22). MS SQL Server qwrFlats.
. ,
PageFlats , 14.17.
SelectAddressStreet
SelectAddressHouse, 14.15.
. 14.2 PageFlats.
14.17. PageFlats
Private Sub Form_Load()
ListBox.RowSource = "SELECT FLAT,STOREY,ROOMS,SQUAREFLAT, " & _
"DWELL,BRANCH,BALCONY,HEIGHT,COST,ACCOUNT " & _
"FROM tblFlats WHERE STREET = " & _
SelectAddressStreet & " AND HOUSE = " & SelectAddressHouse & _
" ORDER BY FLAT"
' " "
ListBox.Selected(0) = True
CommandMain.Enabled = AccountWork
End Sub

ListBox.RowSource
tblFlats, .
, ( 14.18).

14. Microsoft Access

505

14.2. PageFlats

txtStreet

=[]![PageBuilding]!
[ComboStreet].[Column](1)

txtSign

=[]![PageBuilding]!
[ComboStreet].[Column](2)

txtHouse

=[]![PageBuilding]!
[txtHouse].[Value]

ListBox

VBA (. 14.14)

txtCountFlat

=[ListBox].[ListCount]

commandAdd

VBA

commandExit

VBA

14.18. ListBox

Private Sub ListBox_DblClick(Cancel As Integer)
' " "
Dim TxtSQL As String '
IndFlats = 2

'

' : SelectAddressStreet
' : SelectAddressHouse
'
SelectAddressFlat = [ListBox].Column(0)
'
TxtSQL = "SELECT * FROM tblFlats WHERE STREET = " & _
SelectAddressStreet & " AND HOUSE = " & SelectAddressHouse & _
" AND FLAT = " & SelectAddressFlat

III. "-"

506

'
Me.RecordSource = TxtSQL
'
Page2.Visible = True
Page2.SetFocus
'
txtFLAT.Enabled = False
txtFLAT.Locked = True
'
txtACCOUNT.Enabled = False
txtACCOUNT.Locked = True
'
Owners.Enabled = True
End Sub

. 14.23. ( PageFlats)

14. Microsoft Access

507

. 14.23 PageFlats.

, .
.
14.19.
14.19.
Private Sub CommandAdd_Click()
'
Dim TextSQL As String '
IndFlats = 1

'

'
Page2.Visible = True
'
Page2.Caption = " "
'
CommandDoc.Enabled = False
'
CommandTreaty.Enabled = False
'
CommandAccount.Enabled = False
'
CommandDel.Enabled = False
'
CommandMain.Enabled = False
'
txtFLAT.Enabled = True
txtFLAT.Locked = False
'
txtACCOUNT.Enabled = True
txtACCOUNT.Locked = False
'
Owners.Enabled = False
'
DoCmd.GoToRecord , , acNewRec
'

III. "-"

508
txtFLAT.SetFocus

'
Page1.Visible = False
End Sub

Owners
.
,
:
txtACCOUNT.Enabled = True
txtACCOUNT.Locked = False

. 14.24. PageFlats

14. Microsoft Access

509

Enabled (False/True), , , . Locked , .

,
PageFlats, . 14.24.
, ,
/ SlaveAccount
. .
. ( )
,
. PageFlats (. 14.17):
CommandMain.Enabled = AccountWork

AccountWork False/True .
PageFlats
IndFlats.
(1 , 2 ).
, ( 14.20).
14.20. CommandSave
Private Sub CommandSave_Click()
'
On Error GoTo SqlUpdateErr
If IsNull(txtFLAT.Value) Then
'
MsgBox " .", _
vbOKOnly + vbExclamation, ""
'
txtFLAT.SetFocus
'
Exit Sub
End If

III. "-"

510

If IsNull(txtSQUAREFLAT.Value) Then
MsgBox " .", _
vbOKOnly + vbExclamation, ""
txtSQUAREFLAT.SetFocus
Exit Sub
End If
If IsNull(txtDWELL.Value) Then
MsgBox " .", _
vbOKOnly + vbExclamation, ""
txtDWELL.SetFocus
Exit Sub
End If
If IsNull(txtBRANCH.Value) Then
MsgBox " .", _
vbOKOnly + vbExclamation, ""
txtBRANCH.SetFocus
Exit Sub
End If
If IsNull(txtBALCONY.Value) Then
MsgBox " .", _
vbOKOnly + vbExclamation, ""
txtBALCONY.SetFocus
Exit Sub
End If
If IsNull(txtACCOUNT.Value) Then
'
MsgBox " .", _
vbOKOnly + vbExclamation, ""
'
txtACCOUNT.SetFocus
'
Exit Sub
End If
If IndFlats = 1 Then
'
' ?
If DCount("*", "tblFlats", _
"STREET = " & SelectAddressStreet & _

14. Microsoft Access


"AND HOUSE = " & SelectAddressHouse & _
"AND FLAT = " & txtFLAT.Value) > 0 Then
MsgBox " !", _
vbOKOnly + vbExclamation, ""
'
txtFLAT.SetFocus
'
Exit Sub
End If
If MsgBox(" ? ", _
vbInformation + vbYesNo, "") = vbNo Then
DoCmd.RunCommand acCmdUndo
End If
'
DoCmd.RunCommand acCmdSaveRecord
' ( )
Page1.Visible = True
Page1.SetFocus
'
Page2.Visible = False
'
Page2.Caption = " "
'
CommandDel.Enabled = True
'
CommandDoc.Enabled = True
'
CommandTreaty.Enabled = True
'
CommandAccount.Enabled = True
'
CommandDel.Enabled = True
'
CommandMain.Enabled = AccountWork
Page1.SetFocus
End If
If IndFlats = 2 Then
If Me.Dirty Then

511

III. "-"

512

'
If MsgBox(" " & _
" ? ", _
vbInformation + vbYesNo, "") = vbYes Then
'
DoCmd.RunCommand acCmdSaveRecord
End If
End If
Page1.SetFocus
'
ListBox.Requery
End If
Exit Sub
SqlUpdateErr:
Select Case Err.NUMBER
Case 2627
'
MsgBox " .", _
vbOKOnly + vbExclamation, ""
txtACCOUNT.SetFocus
Exit Sub
Case 50001
'
MsgBox "
.", _
vbOKOnly + vbExclamation, ""
Exit Sub
Case Else
'
MsgBox Err.Description
End Select
End Sub

. .
. ,
. , -

14. Microsoft Access

513

. DCount():
If DCount("*", "tblFlats", _
"STREET = " & SelectAddressStreet & _
"AND HOUSE = " & SelectAddressHouse & _
"AND FLAT = " & txtFLAT.Value) > 0 Then
MsgBox " !", _
vbOKOnly + vbExclamation, ""
'
txtFLAT.SetFocus
'
Exit Sub
End If

( ) FK_tblFlats_tvlAccount
tblFlats:
Select Case Err.NUMBER
Case 2627
'
MsgBox " .", _
vbOKOnly + vbExclamation, ""
txtACCOUNT.SetFocus
Exit Sub

. . . ()
. , PK_tblFlats tblFlats,
.
:
[SQUAREFLAT]=[DWELL]+[BRANCH]+[BALCONY]

tblFlats,
14.2. ,
Null. :
1. SQL Server Management Studio.

514

III. "-"

2. Connect to Server. , -

, . Connect.
3. Object Explorer Databases,

.
4. Tables. tblFlats.

. .
5. Modify. (. 14.25).

Allow Nulls SQUAREFLAT, DWELL,


BRANCH BALCONY.

. 14.25. Allow Nulls tblFlats

14. Microsoft Access

515

,
-, . . . :
If IsNull(txtSQUAREFLAT.Value) Then
MsgBox " .", _
vbOKOnly + vbExclamation, ""
txtSQUAREFLAT.SetFocus
Exit Sub
End If

CommandDel,
14.21.
14.21. CommandDel
Private Sub CommandDel_Click()
'
Dim TextSQL As String '
' : SqlUpdateErr
On Error GoTo SqlUpdateErr
' : SelectAddressStreet
' : SelectAddressHouse
'
SelectAddressFlat = [ListBox].Column(0)
TextSQL = "DELETE from tblFlats WHERE STREET = " & _
SelectAddressStreet & _
" AND HOUSE = " & SelectAddressHouse & _
" AND FLAT = " & SelectAddressFlat
If MsgBox(" ? ", _
vbInformation + vbYesNo, "") = vbYes Then
'
DoCmd.RunSQL TextSQL
Page1.SetFocus
ListBox.Requery
Exit Sub
End If
Exit Sub

III. "-"

516
SqlUpdateErr:

Select Case Err.NUMBER


Case 2501
'
MsgBox " .", _
vbOKOnly + vbExclamation, ""
Case 44445
'
' T_tblFlats_DTrig
MsgBox " . !", _
vbOKOnly + vbExclamation, ""
Case Else
'
MsgBox Err.Description
End Select
End Sub

. 14.26. PageFlats

14. Microsoft Access

517

. 14.26 PageFlats . , . . . ,
,
Owners ( 14.22). ,
, ,
, .
14.22. Owners
Private Sub Form_BeforeUpdate(Cancel As Integer)
If MsgBox(" ? ", _
vbInformation + vbYesNo, "") = vbNo Then
DoCmd.RunCommand acCmdUndo
End If
End Sub

14.6.
MS Access 2007, , , , . .
. MS Access, MS SQL Server
2005.

14.6.1.
3 , MS
Access 2007.
. , . , Name ( , ,
). 14.23 MS Access. 14.24 Transact-SQL,
MS SQL- .

III. "-"

518

14.23. Access SQL


SELECT street.NAME, street.SIGN, flats.HOUSE, flats.FLAT,
flats.STOREY, flats.ROOMS, flats.SQUAREFLAT, flats.DWELL,
flats.BRANCH, flats.BALCONY,
flats.HEIGHT, flats.ACCOUNT, flats.FAMILY, flats.NAME,
flats.SECOND, owners.NUMBER, owners.FAMILY, owners.NAME,
owners.SECOND, owners.BORN, owners.STATUS,street.FIRST
FROM street INNER JOIN (flats INNER JOIN owners ON
(flats.HOUSE = owners.HOUSE)
AND (flats.FLAT = owners.FLAT)
AND (flats.STREET = owners.STREET))
ON street.STREET = flats.STREET
WHERE (((flats.FLAT)=[Forms]![Flats]![Flat]))
ORDER BY owners.NUMBER

14.24. (
-, )
:

qwrDocument

. SQL:
CREATE FUNCTION qwrDocument
(@Forms_Building_Street1 varchar (255),
@Forms_Building_House2 varchar (255),
@Forms___Flats___Flat3 varchar (255))
RETURNS TABLE
AS RETURN (SELECT TOP 100 PERCENT
tblStreet.NAME AS NAME2,tblStreet.SIGN,
qwrFlats.HOUSE, qwrFlats.FLAT,qwrFlats.STOREY,
qwrFlats.ROOMS,qwrFlats.SQUAREFLAT,
qwrFlats.DWELL,qwrFlats.BRANCH, qwrFlats.BALCONY,
qwrFlats.HEIGHT,qwrFlats.ACCOUNT AS "_qwrFlats.ACCOUNT_",
qwrFlats.FAMILY,qwrFlats.NAME,qwrFlats.SECOND,
tblOwners.NUMBER, tblOwners.FAMILY AS FAMILY1,
tblOwners.NAME AS NAME1,tblOwners.SECOND AS SECOND1,
tblOwners.BORN,tblOwners.STATUS,

14. Microsoft Access

519

FROM (qwrFlats INNER JOIN tblStreet ON


(qwrFlats.STREET=tblStreet.STREET)) INNER
JOIN tblOwners ON (qwrFlats.STREET=tblOwners.STREET)
AND (qwrFlats.FLAT=tblOwners.FLAT) AND
(qwrFlats.HOUSE=tblOwners.HOUSE)
WHERE (((qwrFlats.FLAT)=@Forms___Flats___Flat3))

qwrDocument Table-valued Functions, :


(@Forms_Building_Street1 varchar (255), --
@Forms_Building_House2 varchar (255),

--

@Forms___Flats___Flat3 varchar (255))

--

,
MS Access.
, -
FROM,
SQL-:
Msg 216, Level 16, State 1, Procedure qwrDocument, Line 2
Parameters were not supplied for the function 'qwrFlats'.

qwrFlats,
qwrDocument, , ,
qwrFlats, .
, ,
( , ), (, , ). :
1. SQL Server Management Studio.
2. Connect to Server. ,

, . Connect.
3. Object Explorer Databases,

.
4. Programmability.

III. "-"

520

5. Stored Procedures. -

. New Stored Procedure....


.
6. , 14.25.
14.25. dbo.Document
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[Document]
(@StreetSql smallint, --
@HouseSql smallint,

--

@FlatSql smallint)

--

AS SELECT dbo.tblFlats.STREET,
dbo.tblStreet.NAME AS NameST,dbo.tblStreet.SIGN,
dbo.tblFlats.HOUSE,dbo.tblFlats.FLAT,
dbo.tblFlats.STOREY, dbo.tblFlats.ROOMS,
dbo.tblFlats.SQUAREFLAT, dbo.tblFlats.DWELL,
dbo.tblFlats.BRANCH,dbo.tblFlats.BALCONY,
dbo.tblFlats.HEIGHT, dbo.tblFlats.ACCOUNT,
dbo.tblAccount.FAMILY, dbo.tblAccount.NAME AS Expr1,
dbo.tblAccount.SECOND, dbo.tblOwners.NUMBER,
dbo.tblOwners.FAMILY AS Expr2,
dbo.tblOwners.NAME AS Expr3,
dbo.tblOwners.SECOND AS Expr4, dbo.tblOwners.BORN,
dbo.tblOwners.STATUS,dbo.tblStreet.FIRST
FROM

dbo.tblStreet INNER JOIN dbo.tblFlats


ON dbo.tblStreet.STREET = dbo.tblFlats.STREET
INNER JOIN dbo.tblOwners ON
dbo.tblFlats.STREET = dbo.tblOwners.STREET AND
dbo.tblFlats.HOUSE = dbo.tblOwners.HOUSE AND
dbo.tblFlats.FLAT = dbo.tblOwners.FLAT INNER JOIN
dbo.tblAccount ON
dbo.tblFlats.ACCOUNT = dbo.tblAccount.ACCOUNT

14. Microsoft Access

521

WHERE (dbo.tblFlats.STREET = @StreetSql) AND


(dbo.tblFlats.HOUSE = @HouseSql) AND
(dbo.tblFlats.FLAT = @FlatSql)
ORDER BY dbo.tblOwners.NUMBER

dbo.Document New Query, . . :


EXECUTE dbo.Document @StreetSql=2,@HouseSql=10,@FlatSql=67

: EXECUTE , @StreetSQL=2 ,
, @HouseSQL=10 ,
@FlatSql=67 , .
! Execute
(. 14.27). .

. 14.27. dbo.Document

14.6.2.
SELECT, , , -

III. "-"

522

.
WHERE HAVING
.
2 Access SQL flat, .
"tbl" Flats, Street Owners
14.26.
14.26. Access SQL
SELECT tblStreet.NAME, tblStreet.SIGN, tblFlats.HOUSE,
tblFlats.FLAT, tblFlats.ROOMS
FROM tblStreet INNER JOIN tblFlats ON
tblStreet.STREET=tblFlats.STREET
WHERE NOT EXISTS
(SELECT * FROM tblOwners
WHERE STREET=tblFlats.STREET AND
HOUSE=tblFlats.HOUSE AND
FLAT=tblFlats.FLAT)
ORDER BY NAME, HOUSE, FLAT;

, , qwrNoOwners Table-valued Functions . , , 14.27.


14.27.
: qwrNoOwners
. SQL:
CREATE FUNCTION qwrNoOwners ()
RETURNS TABLE
AS RETURN (SELECT TOP 100 PERCENT tblStreet.NAME,
tblStreet.SIGN, tblFlats.HOUSE,
tblFlats.FLAT, tblFlats.ROOMS,NAME,HOUSE,FLAT
FROM tblStreet INNER JOIN tblFlats ON (tblStreet.STREET=tblFlats.STREET)
WHERE NOT EXISTS (SELECT * FROM tblOwners

14. Microsoft Access

523

WHERE STREET=tblFlats.STREET AND


HOUSE=tblFlats.HOUSE AND FLAT=tblFlats.FLAT)
ORDER BY NAME,HOUSE,FLAT)

MS SQL Server , , : NAME, HOUSE FLAT ( 14.27 ). ! qwrNoOwners,


14.28, .
14.28. qwrNoOwners
CREATE FUNCTION [dbo].[qwrNoOwners]()
RETURNS TABLE
AS RETURN (SELECT TOP 100 PERCENT tblStreet.NAME,
tblStreet.SIGN, tblFlats.HOUSE,
tblFlats.FLAT, tblFlats.ROOMS
FROM tblStreet INNER JOIN tblFlats ON
(tblStreet.STREET=tblFlats.STREET)
WHERE NOT EXISTS
(SELECT * FROM tblOwners
WHERE STREET=tblFlats.STREET AND
HOUSE=tblFlats.HOUSE AND
FLAT=tblFlats.FLAT)
ORDER BY NAME,HOUSE,FLAT)

, EXECUTE, qwrNoOwners SELECT. :


SELECT * FROM qwrNoOwners()

14.7.
Document Flats,
Real EstateCS,
.

524

III. "-"

StreetSql, HouseSql FlatSql, ,


tblStreet (. 14.28).

. 14.28.

. 14.29. Document

. MS Access (
) , ,
. . -

14. Microsoft Access

525

(. 14.29) :
@StreetSql SmallInt=[Forms]![Building]![Street],
@HouseSql SmallInt=[Forms]![Building]![House],
@FlatSql SmallInt=[Forms]![Flats]![Flat]

? .
.
ADDRESS, :
=IIf([First]=;Trim([tblStreet.Name]+' '+[Sign]+
', '+(Trim([House]))+', .'+Trim(Str([Flat])));Trim([Sign]+
' '+[tblStreet.Name])+', '+(Trim([House]))+', .'+Trim(Str([Flat])))

. 14.30. ,

tblStreet.Name NameST,
dbo.Document (. 14.25):
=IIf([First]=;Trim([NameST]+' '+[Sign]+', '+(Trim([House]))+
', .'+Trim(Str([Flat])));Trim([Sign]+' '+[NameST])+
', '+(Trim([House]))+', .'+Trim(Str([Flat])))

526

III. "-"

, (. 14.29).
tblOwners.FAMILY, tblOwners.NAME tblOwners.SECOND Expr2, Expr3
Expr4 .
(. 14.30).
Flats, Account:
=[]![Flats]![FAMILY]
=[]![Flats]![NAME]
=[]![Flats]![SECOND]

FAMILY, Expr1 SECOND. !

14.8.
, , .
, . 14.29 , ,
. .
14.29.
Public Function LineNumeral(Chislo) As String
' Chislo -
If Chislo > 999999999999# Then
LineNumeral = " "
Exit Function
End If
Dim I, J, K, LK, NK, PART, PRS, FF, Z '
Dim RES As String

'

Dim NN(1 To 4) As Integer

'

Dim RSset As ADODB.Recordset

'

Set RSset = New ADODB.Recordset


RSset.Open "tblNumeral", CurrentProject.Connection
' RSset(0)- tblNumeral ()

14. Microsoft Access


' RSset(1)- tblNumeral ()
Z = 0
If Int(Chislo) = 0 Then
RES = " "
Else
RES = ""
End If
PRS = Right(Space(12) + Str(Int(Chislo)), 12)

'

NN(1) = Val(Mid(PRS, 1, 3))

'

NN(2) = Val(Mid(PRS, 4, 3))

'

NN(3) = Val(Mid(PRS, 7, 3))

'

NN(4) = Val(Mid(PRS, 10, 3))

'

NK = Round((Chislo - Int(Chislo)) * 100) '


For J = 1 To 4
' , ,
For I = 0 To 35
'
' I- :
' ... ... . .
RSset.Move I, adBookmarkFirst
FF = RSset(0)
If (NN(J) >= RSset(1)) Then
If J = 3 Then
'
If NN(J) = 2 Then
PART = " "
Else
If NN(J) = 1 Then
PART = " "
Else
PART = RTrim(FF) + " "
End If
End If
Else
PART = RTrim(FF) + " "
End If
RES = RES + PART

527

III. "-"

528

NN(J) = NN(J) - RSset(1)


' RSset(1) -
Z = RSset(1)
End If
Next I
If Z > 4 Then
K = 1
Else
If Z > 1 Then
K = 2
Else
K = 3
End If
End If
'
' : , . .
RSset.Move 35 + (K + 3 * (J - 1)), adBookmarkFirst
FF = RSset(0)
If Z <> 0 Then
RES = RES + RTrim(FF) + " "
End If
If J = 3 Then
Z = 5
Else
Z = 0
End If
Next J
'
LK = LTrim(Str(NK))
If (Len(LK) < 2) Then
LK = "0" + LK
End If
Select Case NK
Case 1

'

K = 3
Case 2 To 4
K = 2

' , ,

14. Microsoft Access

529

Case Is > 20 ' , . .


Z = NK - Int(NK / 10) * 10
' Z -
Select Case Z
Case 1

'

K = 3
Case 2 To 4

' , ,

K = 2
Case Else

' , , ...,

K = 1
End Select
Case Else
K = 1
End Select
'
' : , . .
RSset.Move 47 + K, adBookmarkFirst
FF = RSset(0)
RES = RES + LK + " " + RTrim(FF) + "."
RSset.Close
Set RSset = Nothing
LineNumeral = RES
End Function

LineNumeral , tblNumeral (. 14.31).


. ,
,
. , .
,
, LineNumeral .
tblNumeral 51 ,
, .
, , .
, ,

530

III. "-"

MS SQL Server ADO.

. 14.31.


.
Recordset ( RSset):
Dim RSset As ADODB.Recordset

'

Set RSset = New ADODB.Recordset

tblNumeral,
:
RSset.Open "tblNumeral", CurrentProject.Connection

, :
RSset.Move <_>, <>

, , (. 14.3).

14. Microsoft Access

531

14.3. Move

adBookmarkCurrent

adBookmarkFirst

adBookmarkLast

LineNumeral
, "" :
RSset.Move I, adBookmarkFirst

, , .

tblNumeral RSset , . . 48,


:
RSset.Move 47, adBookmarkFirst

cNumeral, :
RSset.Fields ("cNumeral").Value

LineNumeral
:
<_> = RSset(0) ' cNumeral
<_> = RSset(1) ' dNumeral

, , (cNumeral) , (dNumeral)
. .

14.9. MS SQL Server 2005 Express Edition


Microsoft SQL Server 2005 Express Edition (SQL Server Express) , Microsoft SQL Server 2005. Microsoft Desktop Engine (

III. "-"

532

MSDE) MS SQL Server 2000. SQL Server Express ,


. SQL Server Express Microsoft .
Microsoft SQL Server 2005 Express Edition , ,
MS Office Access.
. .
, , . ,
, .
, SQL Server Express SQL Server 2005.
:
MS

SQL Server 2005 Express Edition:


SQLEXPR.EXE 53,5 ;

.NET Framework 2.0 ( DOTNETFX.EXE

22,96
).

:
http://www.microsoft.com/downloads/details.aspx?FamilyID=0856eacb4362-4b0d-8edd-aab15c5e04f5&DisplayLang=en#AffinityDownloads;
SQL Server 2005 Management Studio Express

( SQLServer2005_SSMSEE.MSI 39,4 ):
http://www.microsoft.com/downloads/thankyou.aspx?familyId=6053c6f882c8-479c-b25b-9aca13141c9e&displayLang=ru;
MS SQL Server 2005 (-

):
http://www.microsoft.com/downloads/details.aspx?FamilyId=BE6A2C5D00DF-4220-B133-29C1E0B6585F&displaylang=ru.
MS SQL Server 2005 Express Edition , (. 14.32). . 14.4
MS SQL Server 2005 Express Edition.

14. Microsoft Access

533

. 14.32.
MS SQL Server 2005 Express Edition

14.4. MS SQL Server 2005 Express Edition


Visual Studio 2005 MS Access 2007

CLR SQL

(
)

SQL Server
SQL Server

534

III. "-"

14.10. MS SQL Server 2005


MS Access 2007
Microsoft MS Access 2007 MS SQL Server 2005.
, MS Access,
, . , ,
, ,
. .
SQL Server 2005
Management Studio .

14.10.1.
MS Access . MS Access , SQL Server 2005 Management Studio.
MS Access 2007 . ,
. SQL Server 2005 Management Studio
, MS
Access - . :
1. Microsoft Access 2007.
2. . .
3. .

, , .
4. : , ,

.
5. . 1 -

.
6. , ,

.
7. 1. .

14. Microsoft Access

535

8. OK. -

. 14.33.

. 14.33.
MS Office Access 2007

14.10.2. , ,

MS SQL Server 2005 MS Access
, .
, . . MS SQL
Server .

III. "-"

536

.
;
;
;
;
;
;
.

. 14.34. tblDistrict tblBuilding

14. Microsoft Access

537

. 14.34 ,
tblDistrict tblBuilding. ,
MS Access MS SQL Server (. . 12.13). ""
(. 12.112.3),
MS Access 2007. tblBuilding
. . . 14.34 .

14.10.3.
Table-valued Functions
SQL Server 2005 Management Studio , .

. 14.35. qwrFlats Table-valued Functions

Design Query in Editor.


. MS Access 2007

III. "-"

538
qwrFlats,

(. . 14.6) Management Studio. . (. 14.35).


.
, Transact-SQL.

.
SQL. SQL. , .

:
1. Microsoft Access 2007.
2. . .
3. . -

.
4.

OK.
5. 1 .
6. 1.

.
OK.

14.10.4.
MS Access 2007
. 14.6 dbo.Document , Transact-SQL. MS Access:
1. Microsoft Access 2007.
2. . .

14. Microsoft Access

539

3. . -

.
4.

OK.
5. 1

. 14.36. Document

540

III. "-"

Document
tblStreet, tblFlats, tblAccount tblOwners.
(. 14.36). , ,
.
STREET, HOUSE FLAT :
=@StreetSql
=@HouseSql
=@FlatSql


SQL,
Microsoft Access 2007. .
, (Expr1, Expr2, Expr3 . .). ,
Microsoft Access.

.
SQL, .
(. 14.37).

. 14.37.

14.10.5.

, ,

14. Microsoft Access

541

. ,
(, . .), , .
. MS Access
adp-.
1. Office.
2. . -

.
3. SQL- .

.
4. , SQL Server 2005,

. .
5. , dat.


, SQL- .

14.11.

MS Access .
,
, MS Access
"Real EstateCS ". Office,
(. . 14.10).
.
Start , 14.30.
14.30. Start
Private Sub Form_Load()
If Not CurrentProject.IsConnected Then
DoCmd.RunCommand acCmdConnection
End If
End Sub

542

III. "-"

, VBA
MS Access 2007 .

Real EstateCS.adp VBA Real
Estate.ade. ADE. . !
MS SQL-,
MS Access.
, .

/runtime.
. : Y:\Real EstateCS.ade /runtime.
MS Access " ". .
. !



, , .
. 50 . , Real Estate
, .

1
-
"" (. 1.1). :
" ", "" . , , .
. , , .
, , .
1.1. 1

Seller

60

InnSeller

10

546

1.1 ()

Country

15

Chief

60

Address

60

Phone

10

Manager

60

PhonePlus

10

Bank

60

10

Account

20

11

GoodsID

10

12

Goods

30

13

Picture

OLE

14

Category

15

(, )

15

DateStart

16

Period

17

Manufacturer

60

18

Unit

10

19

CostUnit

15

20

Count

21

Client

60

22

InnClient

10

23

Director

60

24

PhoneDir

10

25

Address
Client

60

1.

547

1.1 ()

26

BankClient

60

27

Account
Client

20

28

Volume

29

CostUnitVol

15

30

DateVolume

31

Comment

2
(. 1.2). : (), (), () .
, ,
. .
( ).
, , .
( , , 13 14 ).
() .
1.2. 2

RegNumber

10

548

1.2 ()

RegName

60

Kind

20

(-80,
-80 . .)

Type

20

(,
)

TypeYear

TypeRepair

39

Picture

OLE

Money

15

Bonus

(/ )

10

BonusPercent

()

11

DateStart

12

DateStop

13

Reason

40

14

External

15

BankExternal

60

16

InnExternal

10

17

AddressExternal

80

18

FIOchief

40

19

Base

15


()

20

FIOworker

40

21

BaseWorker

15

()

1.

549

1.2 ()

22

YearWorker

23

SpecialWorker

30

24

BonusWorker

15

25

Comment

Memo

( )

26

Number BankKart

60

3

"" (. 1.3). .
. . .
. . .
. , .
1.3. 3

RegNumber

10

Name

60

Skipper

60

550

1.3 ()

Type

15

(, )

Capacity

10

Year

Picture

OLE

Dockyard

15

CustomValue

10

10

DepartureDate

11

ArriveDate

12

Origin

20

13

Destination

20

14

CustomClearan
ce

15

Number

16

Shipment

30

17

DeclareValue

18

Unit

10

19

InsureValue

20

Sender

30

21

INNsender

10

22

BankSender

60

23

AddressSender

80

24

Consignee

30

1.

551

1.3 ()

25

INNconsignee

10

26

BankConsignee

60

27

AddressConsig
n

80

28

Comment

Memo

4

(. 1.4).
(, , ).
,
. . ,
.
.
1.4. 4

Kadastr

20

Address

60

District

15

Land

10

Year

Material

15

552

1.4 ()

Base

15

Comment

Memo

Wear

10

Flow

11

Line

12

Square

10

13

Picture

OLE

14

Flats

15

Elevator

16

Flat

17

Storey

18

Rooms

19

SquareFlat

20

Dwell

21

Branch

22

Balcony

23

Height

24

Record

25

Document

60

26

DateDoc

27

FioHost

60

28

Passport

Memo

1.

553

1.4 ()

29

Part

, %

30

Born

5
- "" (. 1.5).

.
"" 80 .
30 .
, .
"" . . - , .
1.5. 5

EmployeeID

EmployeeName

60

Address

60

District

15

Experience

Year

Language

15

554

1.5 ()

Base

15

()

Comment

Memo

10

Salary

15

11

Bonus

15

12

GrossSalary

15

13

Exempt

15

14

Picture

OLE

15

ProjectID

16

Project Name

40

17

ProjectStart

18

ProjectStop

19

Chief

60

20

Customer

60

21

Cost

22

Phone

10

23

Bank

60

24

Account

20

25

INN

10

26

Address Cust

60

27

FioWorker

60

28

Phone Worker

10

29

BonusAll

(%)

1.

555

1.5 ()

30

Employee
Start

31

Employee
Stop

6
"" (. 1.6).
. ,
, .
,
, . .
,
.
.
.
1.6. 6

Provider

40

INN

10

Address

60

Bank

60

Account

20

Sign

556

1.6 ()

Film

20

Script

60

Comment

Memo

10

Producer

60

11

Company

40

12

Year

13

Expense

15

14

Cost

15

15

Translate

16

Cinema

20

17

INNcinema

10

18

Address
Cinema

60

19

Chief

60

20

Owner

60

21

BankCinema

60

22

Phone

10

23

District

15

24

Account
Cinema

20

25

Capacity

26

DateStart

27

DateStop

28

PhoneWorker

10

1.

557

1.6 ()

29

Worker

60

30

Summa

15

31

Tax

15

7
(. 1.7).
. 450 .
( ). TO-2 . -3
150 . .
, . : , . . . : ,
, , , .
(-1, -2, -3 . .). . , , . .
1.7. 7

RegNumber

10

RegName

60

RegChief

20

558

1.7 ()

Type

20

(,
. .)

TypeYear

TypeRepair

39

Picture

OLE

Money

15

Bonus

(/ )

10

BonusPercent

()

11

DateStart

12

DateStop

13

Reason

40

14

External

15

BankExternal

60

16

InnExternal

10

17

Address External

80

18

FIOchief

40

19

Base

15

()

20

FIOworker

40

21

BaseWorker

15

()

22

YearWorker

1.

559

1.7 ()

23

SpecialWorker

30

24

BonusWorker

15

25

Comment

Memo

( )

26

Number BankKart

60

8

LADA- (. 1.8). .
. ,
- . , , . , , .
, .
, .
.
1.8. 8

IDfilial

Filial

20

InnFilial

10

Chief

60

560

1.8 ()

Capacity

Address

60

Phone

10

Brand

15

Model

15

10

BodyID

20

11

EngineID

20

12

BodyModel

20

13

Picture

OLE

14

Volume

15

Power

, ..

16

Helm

(/)

17

Drive

18

DateStart

19

Cost

15

20

New

21

Year

22

Distance

23

Type

15

24

Client

60

25

Sign


(./. )

26

Bank

60

1.

561

1.8 ()

27

Account

20

28

Comment

Memo

29

Customer

60

30

Price

15

31

StartDate

9
" " (. 1.9).
, . , ,
,
. , . , , ,
.
1.9. 9

IDfilial

Filial

20

InnFilial

10

Chief

60

562

1.9 ()

Capacity

Address

60

Phone

10

GoodsID

15

Goods

40

10

Categoty

20

(, )

11

Country

20

12

Company

40

13

Picture

OLE

14

INNcompany

10

15

AdddressComp

60

16

DateStart

17

Period

18

DateBuy

19

Cost

15

20

Fax

12

21

PhoneCompany

12

22

Email

20

23

Web

20

Web-

24

CostRepair

15

25

CustomerID

26

Customer

60

1.

563

1.9 ()

27

AddressCust

60

28

Comment

Memo

(
)

29

Sign

(./.
)

30

Guarantee

31

StartDate

32

StopDate

10

(. 1.10). . . , , .
. "".
.
: ,
. ,
, .
1.10. 10

Number

15

Battalion

30

564

1.10 ()

Commander

50

Rank

20

ViceCommander

50

Rank2

20

Photo

OLE

Commander2

50

Rank3

20

10

Passport

20

11

CompanyID

12

CompanyName

20

13

Photo2

OLE

14

PlatoonID

15

Commander3

50

16

Rank4

20

17

Photo3

OLE

18

PlatoonName

20

19

DepartmentID

20

Soldier

50

21

Post

20

(/)

22

Rank5

20

23

Start

1.

565

1.10 ()

24

Stop

25

Kind

( )

26

Address

60

27

Phone

15

28

Comment

Memo

29

Birth

11

" " (. 1.11). .
: , , , , . .
,
.
. : , ,
, , , . .
(, , ) .
1.11. 11

Number

Block

20

Address

60

District

15

566

1.11 ()

Inventory

Land

Actual

BuildUp

Yard

10

Green

11

Garden

12

Bad

13

Picture

OLE

14

Light

15

WaterPipe

16

Heating

17

Comment

Memo

18

Letter

()

19

Contents

20

20

Type


(./)

21

MySelf

22

Year

23

SquareAll

24

Inhabited

25

Wear

26

Wall

15

1.

567

1.11 ()

27

Cost

15

28

Storeys

29

NumberSign

30

Prescribe

20

31

SquareRoom

32

HighRoom

33

Storey

12
(. 1.12). : , . ,
, ( , ) (, ).
: , .

.
. , .
1.12. 12

PersonID

568

1.12 ()

Name

40

Department

40

Institute

40

()

Birth

Place

20

Address

60

Phone

15

Education

40

10

Year

11

Speciality

30

12

Picture

OLE

13

DegreeYes

(/)

14

Degree

15

Rank

16

Post

20

17

Comment

Memo

18

Passport

20

19

PassportDate

20

Region

40

21

WorkBegin

22

WorkEnd

1.

569

1.12 ()

23

Work

20

24

WorkPlace

20

25

WorkAddress

60

26

WorkPhone

15

27

Reason

30

28

Penalty

Memo

29

Rewards

Memo

13

(. 1.13). , , .
. . . ,
,
.
, .
, .
1.13. 13

JoblessID

LastName

20

570

1.13 ()

FirstName

20

Patronymic

20

Age

Passport

20

PassportDate

Region

40

Address

60

10

Phone

15

11

Picture

OLE

12

StudyPlace

60

13

StudyAddress

60

14

StudyType

15

(
. .)

15

Registrar

15

16

RegDate

17

Payment

15

18

Experience

(/)

19

Comment

Memo

20

ArchivesDate

21

Archivist

15

22

JobID

23

JobType

20

(,
. .)

1.

571

1.13 ()

24

JobName

20

25

JobGiver

20

26

Place

60

27

Mobile

15

28

District

15

29

Money

15

30

More

Memo

14

" " (. 1.14). .
1.14. 14

Kadastr

20

Address

60

District

15

Land

10

Year

Material

15

572

1.14 ()

Base

15

Comment

Memo

Wear

10

Flow

11

Line

12

Square

10

13

Picture

OLE

14

Flats

15

Elevator

16

Flat

17

Storey

18

Rooms

19

Level

20

SquareFlat

21

Dwell

22

Branch

23

Balcony

23

Height

25

Record

26

SquareRoom

27

Size

40

28

Name

30

(, . .)

1.

573

1.14 ()

29

Decoration

60

(, ...)

30

HeightRoom

31

Socket

32

Sections

15

(. 1.15).
.
, (, , . .) ,
, . . . . - ,
, , , .
1.15. 15

GoodsID

10

Name

40

International

40

Begin

574

1.15 ()

Yes


(/)

RF

20

Producer

60

Instructions

Memo

10

Batch

20

11

Seller

20

12

Address

60

13

Phone

15

14

INN

10

15

Sign

16

Date

17

Price

10

18

GoodsInvoice

19

ClientID

20

Company

25

21

Address

60

22

Phone

15

23

CountNumber

End

1.

575

1.15 ()

Sum

15

26

Cash

(/)

27

Worker

60

28

Invoice

29

INNClient

10

30

Seller

15

24

DateStart

25

16

" " (. 1.16).
, 16 000 . (, ), , , . .
(, , ). 265 000 . , . ,
.
1.16. 16

Kadastr

20

Address

60

576

1.16 ()

District

15

Land

10

Year

Material

15

Base

15

Comment

Memo

Wear

10

Flow

11

Line

12

Square

10

13

Picture

OLE

14

Hall

15

Elevator

16

HallNum

17

Storey

18

Rooms

19

Level

20

SquareHall

21

Branch

22

Balcony

23

Height

24

Record

1.

577

1.16 ()

25

SquarePart

26

Size

40

27

NamePart

30

(,
. .)

28

Decoration

60

(, . .)

29

HeightPart

30

Socket

31

Sections

17


(. 1.17).
. ,

. , , . 2002 . (13% ), ,
, . ., , .
1.17. 17

INN

13

578

1.17 ()

LastName

20

FirstName

20

Patronymic

20

Document

80

Serial

10

Number

20

Date

Region

30

10

Born

11

Picture

OLE

12

DateTax

13

NumberTax

12

14

Address

80

15

District

20

16

DistrictTax

20

17

TaxNumber

18

Enterprise

40

19

InnEnterprise

10

20

AddressWorks

30

21

Chief

60

22

Phone

10

23

SumAll

15

1.

579

1.17 ()

24

SumTax

15

25

SumPension

15

26

ExemptType

60

27

Exempt

15

28

Comment

Memo

18

"" (. 1.18). -, .
. , . .
.
, . , . , , ,
.
1.18. 18

CustomerID

CustomerType

(./. )

580

1.18 ()

CustomerFio

60

( . )

CustomerName

60

( .
)

CustomerInn

13

( . )

Chief

40

( . )

Phone

10

Address

60

Bank

60

( . )

10

District

15

11

Discont

12

MasterID

13

MasterFio

60

14

Experience

15

Defect

16

RepairAll

17

TypeID

18

Type

15

(,
. .)

19

Country

15

20

Company

40

21

Picture

OLE

22

Age

23

DateStart

1.

581

1.18 ()

24

DateStop

25

Summa

15

26

Period

27

Guarantee

(/)

28

Comment

Memo

19
(. 1.19).
.
, .
, , , . -
.
. , .
1.19. 19

Hostel

Address

60

District

15

Picture

OLE

582

1.19 ()

Owner

20

Rooms

Beds

RoomID

Square

10

10

Comment

Memo

11

RoomBeds

12

Type

(
. .)

13

Storey

14

Lodger

15

Name

40

16

Passport

20

17

PassportDate

18

Region

40

19

Work

20

20

Children

(/)

21

DocumentID

22

Document

20

23

Begin

24

Giver

20

1.

583

1.19 ()

25

DocComment

Memo

26

Payment

27

Settlement

28

End

29

Reason

Memo

20
(. 1.20). .
. . .
, , .
1.20. 20

OwnerID

OwnerType

(./. )

OwnerFio

60

( . )

OwnerName

60

OwnerInn

10

584

1.20 ()

Chief

60

Phone

10

Address

60

District

15

10

Number

10

11

Brand

15

12

Model

15

13

BodyID

20

14

EngineID

20

15

BodyModel

20

16

Color

20

17

Volume

18

Comment

Memo

19

Power

. .

20

Helm

(/)

21

Drive

22

Year

23

TypeBody

15

(,
)

24

DrivingAway

25

DateAway

1.

585

1.20 ()

DateSee

28

Inspector

60

29

YearTax

15

30

YearNumber

15

31

Work

15

32

Distance

33

Okey

34

Reason

Memo

26

DateReturn

27

21
(. 1.21).
. , , , , . . - . , ,
. ,
. , , .
.

586

1.21. 21

Kadastr

BuildingName

20

()

Land

Address

60

Year

Material

15

Wear

Flow

Picture

OLE

10

Comment

Memo

11

HallID

12

Square

13

Windows

14

Heating

15

Target

15

(,
. .)

16

Department

15


()

17

Chief

30

18

DepartmentID

19

DepartmentName

15

1.

587

1.21 ()

20

Boss

40

21

Phone

10

22

OfficeDean

30

23

ChiefID

24

AddressChief

60

25

Experience

26

UnitID

27

UnitName

30

28

DateStart

29

Cost

15

30

CostYear

31

CostAfter

15

32

Period

22
"" (. 1.22).

. .
-

588

. . "" ,
.
,
, . - , ,
.
1.22. 22

ClientID

LastName

20

FirstName

20

Patronymic

20

Document

80

Serial

10

Number

20

Date

Region

30

10

Born

11

Picture

OLE

12

Pasport

13

RouteID

14

RouteName

30

15

Country

20

16

Period

1.

589

1.22 ()

17

Worker

20

18

Cost

15

19

Exempt

15

20

Return

15

21

DateStart

22

Town

15

23

Count

24

Hotel

15

25

StartDate

26

StopDate

27

Type

(***, ****)

28

Comment

Memo

23
(. 1.23).
. ,
( ).
"" , .
. .
. . -

590

, , .
1.23. 23

DoctorID

LastName

20

FirstName

20

Patronymic

20

Room

University

40

()

Type

20

(,
. .)

Experience

Phone

10

10

Born

11

Picture

OLE

12

Fio

60

13

Number

10

14

Address

80

15

District

20

16

PolicyNumber

20

17

Year

18

Sign


(/)

1.

591

1.23 ()

19

Department

40

20

TreatyID

10

21

DateStart

22

TimeStart

10

23

Cost

15

24

ExemptID

25

ExemptType

60

(,
)

26

Exempt

15

27

Summa

15

28

Comment

Memo

(
)

24
"Rapid" (. 1.24). , .
,
.
. ,
. . , . .
.
.

592

1.24. 24

RegNumber

10

Address

60

District

15

Orientation

60

(,
-2 . .)

Square

Size

10

CustomerID

10

Status

15

(,
, )

Customer

40

10

AddressCust

60

11

Chief

40

12

Phone

10

13

Bank

60

14

Account

20

15

Tax

15

16

Worker

40

17

PhoneWorker

10

18

TreatyID

19

DateStart

20

StopDate

21

SignDate

22

Advertisment


(/)

1.

593

1.24 ()

23

Cost

15

24

Leasing

15

25

Picture

OLE

26

Employee

40

27

Period

15

(, , )

28

Comment

Memo

25
OOO "
" (. 1.25). .
, - .
, , ,
, "
" .
, .
.
-.
1.25. 25

Registr

10

594

1.25 ()

Address

60

Name

60

Phone

10

TreatyID

AddressFlat

60

District

15

Floors

Floor

10

TypeHouse

20

(, )

11

TypePlan

20

(,
)

12

TypeToilet

20

(, )

13

SqAll

14

SqLife

15

SqKit

16

Agent

40

"
..."

17

Privat

18

SignPhone

19

DateStart

20

StopDate

21

Cost

15

1.

595

1.25 ()

22

Bonus

15

"
..."

23

Picture

OLE

24

Plan

OLE

25

Structure

Memo

26

Document

40

27

Prolong

28

Comment

Memo

26
(. 1.26). .
. . -
. , , ,
. , .
.

596

1.26. 26

Registr

10

Address

60

Name

60

Phone

10

TreatyID

AddressFlat

60

Key

Floors

Floor

10

TypeHouse

20

(, )

11

TypeDoor

20

(, ,
)

12

Balcony

13

TypeBalcony

60

(, )

14

Plan

OLE

15

Cost

15

16

Compensation

15

17

DateStart

1.

597

1.26 ()

18

StopDate

19

ActionID

20

PatrolID

21

Chief

20

22

Brand

15

23

DateTime

24

False

(/)

25

Tax

15

26

Document

40

27

Prolong

28

Comment

Memo

27
(. 1.27).
""
. .
. ,
, () ,
.
.

598

1.27. 27

Address

60

District

15

Balance

60

Year

Material

15

Base

15

Comment

Memo

Wear

Flow

10

Line

11

Square

10

12

Hall

13

Picture

OLE

14

Flats

15

Elevator

16

Flat

17

Storey

18

Rooms

19

SquareFlat

20

Dwell

21

Branch

22

Balcony

1.

599

1.27 ()

23

Height

24

Record

25

Document

60

26

DateDoc

27

Cost

27

FioHost

60

28

Pasport

Memo

29

Sign


(/)

30

Born

31

Status

20

28

""
(. 1.28). , . .
. .
, .
.

600

1.28. 28

Address

60

District

15

Material

15

Floor

15

Picture

OLE

Owner

15

Doorway

Flats

LastName

20

10

FirstName

20

11

Patronymic

20

12

Passport

20

13

Flat

14

FlatType

15

People

16

Phone

15

17

Account

15

18

DateCount

19

Stop

20

Number

10

21

ViewNumber

22

MadeIn

15

1.

601

1.28 ()

23

WhenMade

24

DateView

25

Result

26

PayMonth

27

Prophylaxis

28

PayDefect

29

Surname

20

29
" "
(. 1.29). . 200 .
.
, . .
, ,
, .
. . . . ,
. (
) , .

602

1.29. 29

NumberClaim

10

Name

60

Phone

10

Receipt

Bank

60

Account

20

Address

60

District

15

DateStart

10

Document

60

11

Speed

(/)

12

DateStop

13

Cost

15

14

Inspector

15

Time

20

16

Chief

30

17

Worker

30

18

DateWorker

1.

603

1.29 ()

19

Helper

30

20

Cash

(/)

21

DateCost

22

Value

15

23

Finish

(/)

24

Comment

Memo

30

"" (. 1.30). ,
,
. .
, "". 12-
, 300 .
. ,
. .
.
.
.

604

1.30. 30

CustomerID

CustomerType


(./. )

CustomerFio

60


( . )

CustomerName

60


( . )

CustomerInn

13


( . )

Chief

40

( . )

Phone

10

Address

60

Bank

60


( . )

10

District

15

11

Worker

30

12

PhoneWorker

10

13

HallID

14

Square

15

Size

20

16

Floor

17

PhoneHall


(/)

18

Decoration

10

(, , )

1.

605

1.30 ()

19

TreatyID

20

Type

21

DateStart

22

DateStop

23

Period

20

(, )

24

Value

15

25

Inspector

30

26

Target

30

(, ,
)

27

Tax

15

28

Comment

Memo

31

(. 1.31).
.
, . . . .
. ,

606

.
.
1.31. 31

CustomerID

CustomerType

(./. )

CustomerFio

60

( . )

CustomerName

60


( . )

CustomerInn

13

( . )

Chief

40

( . )

Phone

10

( .
)

Address

60

Bank

60

( . )

10

Account

20

11

PhoneNumber

10

12

PhoneAddress

60

13

Value

15

14

ExemptType

20

15

Exempt

15

16

DateClaim

17

NumberClaim

18

Inspector

15

1.

607

1.31 ()

Compensation

15

21

DateRing

22

RingType

23

Number

10

24

County

15

25

Town

15

26

Value

27

Summa

15

28

Comment

Memo

19

DateRepair

20

32
(. 1.32). ,
,
. , , . . , ,
. .
. , . .

608

1.32. 32

Provider

40

INN

10

Address

60

Bank

60

Account

20

Sign

Film

20

Author

60

Comment

Memo

10

Pages

11

Company

40

12

Year

13

Cost

15

14

Cdrom

15

Customer

20

16

CustomerSign

(./.)

17

INNcustomer

10

18

AddressCust

60

19

Chief

60

20

BankCustomer

60

21

Phone

10

1.

609

1.32 ()

22

District

15

23

AccountCust

20

24

CountNumber

25

DateStart

26

Value

15

27

Worker

60

28

Tax

15

29

Plus

Memo

33
"" (. 1.33).
.
. .
2,5.
. .
.
.
.
.
. . , .

610

1.33. 33

LastName

20

FirstName

20

Patronymic

20

Experience

Year

Category

20

(D, E)

Class

20

(1, 2, 3)

DriverID

BusNumber

10

Brand

15

11

Picture

OLE

12

Model

15

13

Capacity

14

YearBus

15

YearRepair

16

Distance

17

RouteID

18

PointStart

20

19

PointStop

20

20

DateStart

21

TimeStart

10

22

TimeAll

10

1.

611

1.33 ()

23

PlaceNumber

24

PlaceSign


(/)

25

SumDriver

15

26

SumTax

15

27

Comment

Memo

34

(. 1.34). . :
, ,
, . . , , . ,
,
.
. , ,
.
1.34. 34

CandidateID

Name

40

612

1.34 ()

Gender

Age

Myself

Memo

Demand

Memo

Phone

15

Picture

OLE

Registrar

15

10

RegDate

11

ClientID

12

ClientName

40

13

ClientGender

14

ClientPhone

15

15

Date

16

ClientMyself

200

17

ClientMore

50

18

ClientAge

19

ReceiptID

20

PayDate

21

Seller

15

22

Cash

(/)

23

Sum

24

MeetDate

1.

613

1.34 ()

25

MeetTime

26

InvitationID

27

DeleteDate

28

Deleter

15

29

Reason

30

35

(. 1.35). ,
. , , , . . .
:
, , , . .
1.35. 35

ClientID

Name

40

Date

Address

60

614

1.35 ()

District

15

Phone

15

Passport

20

PassportDate

Region

40

10

Agreement

11

StartDate

12

PercentDate

13

StopDate

14

Registrar

15

15

ThingID

16

Category

15

17

Thing

30

18

Count

19

Defects

(/)

20

Cost

10

21

Sum

10

22

Comment

Memo

23

Back

1.

615

1.35 ()

24

Tax

10

25

BackSum

10

26

Seller

15

27

FreeThing

28

Price

10

36

(. 1.36). : (, . .), , , ,
, , , . , , , , .
, . .
1.36. 36

GuestID

Name

40

Date

616

1.36 ()

Address

60

Town

20

Aim

30

Passport

20

PassportDate

Region

40

10

Work

20

11

Year

12

Money

10

13

Cash

(/)

14

Receipt

15

End

16

Comment

Memo

17

Registrar

15

18

Picture

OLE

19

Number

20

Rooms

21

Storey

22

TV

(/)

23

Fridge

(/)

24

Bed

25

Type

1.

617

1.36 ()

26

Balcony

(/)

27

Reservation

28

ReservName

40

29

Come

30

Leave

37
(. 1.37). , . : .
. , ,
, , (, , ) . . , . ,
.
, .
1.37. 37

SortID

10

Name

40

Year

618

1.37 ()

Adaptation

(/)

Frost

(/)

Description

200

Technology

Memo

Picture

OLE

Part

10

10

End

11

Yes

(/)

12

Batch

20

13

Amount

14

BatchTime

15

Weight

16

Period

17

NewSort

18

Date

19

Comment

Memo

20

ClientID

21

Company

25

22

BuyDate

23

Address

60

24

Phone

15

25

Sum

10

1.

619

1.37 ()

26

Cash

(/)

27

Seller

15

38

(. 1.38).
. : ,
; , , , - .
,
.
1.38. 38

PersonID

Name

40

Date

Picture

OLE

Address

60

Phone

15

620

1.38 ()

Birth

School

20

Money

(/)

10

Passport

20

11

PassportDate

12

Region

40

13

Attestat

20

14

Middle

15

Faculty

40

16

Speciality

40

17

Registrar

15

18

Talk

19

Result

20

Contract


(/)

21

ContractID

10

22

ContractAbout

Memo

23

ContAddress

60

24

ontPhone

15

25

Payment

(/)

26

EGE

20

1.

621

1.38 ()

27

Lesson

20

28

Score

29

YesID

30

Type

39
(. 1.39).
. ,
: , , (, ). , , , "
" . .
, , , ,
.
1.39. 39

Passage

Title

40

Date

Time

622

1.39 ()

Arrival

ArrivalTime

Seats


(/)

Places

50

Passenger

10

Name

40

11

Date

12

Passport

20

13

PassportDate

14

Region

40

15

Till

16

Ticket

10

17

Chair

18

Class

19

Price

20

Registrar

15

21

Airliner

10

22

AirlinerName

15

23

Year

24

Picture

OLE

25

Amount

1.

623

1.39 ()

26

Repair

27

Crew

28

Pilot

15

29

CrewNames

Memo

40

(. 1.40).
, .
. (, ), (
), (, ).
.
.
1.40. 40

Address

60

District

15

Material

15

Floor

15

Picture

OLE

624

1.40 ()

Owner

15

Doorway

Flats

LastName

20

10

FirstName

20

11

Patronymic

20

12

Passport

20

13

Flat

14

FlatType

15

People

16

EStove

(/)

17

Number

10

18

Kind

19

Type

20

Factor

21

Comment

Memo

22

Tariff

23

Day

24

Night

25

24hour

26

BeginMonth

27

EndMonth

1.

625

1.40 ()

28

Privilege

29

Surname

20

41
(. 1.41).
. , :
, , , (, , ).
, ,
"
" . .
, , , , .
1.41. 41

Passage

Title

40

Date

Time

Arrival

ArrivalTime

626

1.41 ()

Seats


(/)

Places

50

Passenger

10

Name

40

11

Date

12

Passport

20

13

PassportDate

14

Region

40

15

Till

16

Ticket

10

17

Chair

18

Class

19

Price

20

Registrar

15

21

Airliner

10

22

AirlinerName

15

23

Year

24

Picture

OLE

25

Amount

26

Repair

27

Crew

1.

627

1.41 ()

28

Pilot

15

29

CrewNames

Memo

42
(. 1.42). , , , ,
. , ,
.
"". 10- . ,
, .


.
1.42. 42

Number

10

Date

Name

255

FileName

PDF-,

628

1.42 ()

FolderName

Comment

Memo

Source

100

(, , )

Town

20

PostIndex

10

Email

40

11

PhoneSource

20

12

FaxSource

20

13

Sign

(/ )

14

Department

100

15

Director

60

16

Point

17

Power

50

18

Chief

60

19

Slave

60

20

Answer

10

21

DateAnswer

1.

629

1.42 ()

22

NameAnswer

255

23

FileAnswer

PDF-,

24

FolderAnswer

25

CommentAns

Memo

26

PhoneAnswer

20

27

SubSlave

60

43

(. 1.43). .
( ) 18 ,
.
.
.
.
1.43. 43

Address

60

District

15

630

1.43 ()

Material

15

Floor

15

Picture

OLE

Owner

15

Doorway

Flats

LastName

20

10

FirstName

20

11

SecondName

20

12

Passport

20

13

Flat

14

FlatType

15

People

16

Type

(/)

17

Number

10

18

Kind

19

Type

20

DateTest

21

Comment

Memo

22

Tariff

23

Count

24

Sign

(/)

1.

631

1.43 ()

25

Square

26

BeginMonth

27

EndMonth

28

Privilege

29

Surname

20

44
(. 1.44). , .
,
. ,
. ,
.
. -
, , ,
, .
.
1.44. 44

GoodsID

10

632

1.44 ()

Name

40

International

OLE

Begin

End

NumberYes

DateYes

20

Producer

60

Instructions

Memo

10

Batch

20

11

Seller

20

12

Address

60

13

Phone

15

14

INN

10

15

Sign

16

Date

17

Price

10

18

GoodsInvoice

19

ClientID

20

Company

25

21

Address

60

22

Phone

15

1.

633

1.44 ()

23

CountNumber

24

DateStart

25

Sum

15

26

Cash

(/)

27

Worker

60

28

Invoice

29

INNClient

10

30

Seller

15

45

(. 1.45).
.
.
. ( ) . , , .
. .
1.45. 45

PersonID

Name

40

634

1.45 ()

Department

40


( )

Institute

40

() ( )

Birth

Place

20

Address

60

Phone

15

Education

40

10

Year

11

Speciality

30

12

Picture

OLE

13

DegreeYes

(/)

14

Degree

15

Rank

16

Post

20

17

Comment

Memo

18

Passport

20

19

PassportDate

20

Region

40

21

SubjectId

1.

635

1.45 ()

22

Code

15

23

CountHours

24

CourseWork

(/)

25

Examination


(/)

26

NameId

27

Sign

10

(,
, )

28

ISBN

10

29

BookYear

30

Press

40

31

Pages

32

DocNumber

33

Paper

50

34

Document

46

(. 1.46). .
. . .
. ,

636

,
.
1.46. 46

PersonID

Name

40

Department

NameId

Birth

Place

20

Address

60

Phone

15

Picture

OLE

10

Comment

Memo

11

Passport

20

12

PassportDate

13

Region

40

14

SubjectId

15

Code

15

16

CountHours

17

CourseWork

18

DateWork

1.

637

1.46 ()

19

Examination

20

DateExam

21

NameId

27

Sign

10

(,
, )

28

ISBN

10

29

Enter

30

DocNumber

31

Out

32

Document

47
"
" (. 1.47).
.
. . -

. , , , . ,
. .

638

1.47. 47

Kadastr

Address

60

Name

60

Phone

10

TreatyID

AddressFlat

60

Key

Floors

Floor

10

TypeHouse

20

(, )

11

TypeDoor

20

12

Balcony

13

TypeBalcony

60

(, )

14

Plan

OLE

15

Cost

15

16

Compensation

15

17

DateStart

18

StopDate

19

ActionID

1.

639

1.47 ()

20

PatrolID

21

Chief

20

22

Brand

15

23

DateTime

24

False

(/)

25

Tax

15

26

Document

40

27

Prolong

28

Comment

Memo

48
(. 1.48).
. , (
). "" , .
. .
.
. .

640

1.48. 48

Name

60

NumberID

10

Address

80

District

20

PolicyNumber

20

Year

Sign

(/)

Department

40

DateStart

10

DateStop

11

Cost

15

12

ExemptID

13

ExemptType

60

(, )

14

Exempt

15

15

Summa

15

16

Comment

Memo

(
)

17

Company

60

18

CompAddress

60

19

Bank

40

20

Inn

10

1.

641

1.48 ()

21

Chief

60

22

Doctor

60

23

DoctorID

24

University

40

()

25

Type

20

(,
. .)

26

Experience

27

DoctorExt

60

( )

28

DoctorIDExt

29

UniversityExt

40

30

TypeExt

20

(,
. ..)

31

ExperienceExt

49

(. 1.49). . . .
.

. .

642

1.49. 49

CandidateID

LastName

20

FirstName

20

SecondName

20

Age

Passport

20

PassportDate

Region

40

Address

60

10

Phone

15

11

Picture

OLE

12

StudyPlace

60

13

StudyAddress

60

14

StudyType

15

(
. .)

15

Registrat

15

16

RegDate

17

Place

15

18

Experience

19

Comment

Memo

20

ArchivesDate

21

Archivist

15

1.

643

1.49 ()

22

JobID

23

JobType

20


(, )

24

JobName

20

25

JobGiver

20

26

Place

60

27

Mobile

15

28

District

15

29

Money

15

30

More

Memo

50
(. 1.50).
. 2007 .
.
.
. . . .
.
.
.
, -

644

.
.
1.50. 50

CustomerID

CustomerType

(

)

CustomerFio

60

( . )

CustomerName

60

( )

CustomerInn

13

Chief

40

MapPhone

10

DateMap

60

MapCount

10

Account

20

11

Bank

50

12

PhoneAddress

60

13

Value

15

14

ExemptType

20

15

Exempt

15

16

DateClaim

17

NumberClaim

18

Inspector

15

1.

645

1.50 ()

Compensation

15

21

DateRing

22

RingType

23

Number

10

24

County

15

25

Town

15

26

Value

27

Summa

15

28

Comment

Memo

19

DateRepair

20

-
- , Real Estate (. 2.1). 3
6 :
Building ;
Help , -

- ;
Photo ;
Real Estate.accdb MS Access 2007, -

II;
Real EstateCS.adp MS Access, -

MS SQL Server 2005;


Real EstateCS_ade.ade MS Access,

MS SQL Server 2005, VBA;


Real EstateCS.dat Real EstateSQL;
RealEstate.chm Real

Estate;
Real Estate.rtf MS Access

2007 MS SQL Server 2005.


MS Access 2007 , , Real Estate.accdb.

2. -

647

. 2.1. -

"-" .
1. MS SQL Server 2005.
2. SQL Server Management Studio SQL Server Management Stu-

dio Express.
3. Connect to Server ( ).

, , .
Connect ().
4. Object Explorer Databases

( ) . .
5. Restore Database ( ). -

.
6. To Database : Real EstateSQL.
7. From device.
8. ,

. Specify Backup.
9. Add. .

648

10. Real EstateCS.dat, -,

OK. Specify
Backup.
11. OK. Specify Backup ,

, , Restore Database.
12. Select the

backup sets to restore, Restore (. 2.2).

. 2.2. MS SQL Server 2005

2. -

649

13. OK. -

.
14. Restore Database , Real EstateSQL

Object Explorer.
15. SQL Server Management Studio.
16.

-.
EstteCS.dat .

Real

17. Real EstateCS.adp -

VBA Real EstateCS.ade.


18. .
19. , . -

OK.

A
ActiveX Data Objects 308
ADO 310
ADO.NET 406
ADODB 312
ALL 430
AllowBypassKey 235
Alphabetic 168
Alter table 215
ANY 431
Asc() 253

B
BEGIN CATCH 438
BEGIN TRY 438
BETWEEN 431
Bit 144
Byte 173

C
Case ... End 435
CAST() 422
Cell 348
Chr() 253
Convert() 422, 493
Copyright 345
Count() 199
Create 212
Create index 218
CreateObject 331
Currency 173

D
DAO 406
Date() 493
DCount() 208, 271
DDL 211
DECLARE 428
Delete 211
Dim 171
DISALLOW NULL 219
Distinct 197
Double 173
Drop 217

E
EXISTS 431

F
From 195

G
GetDate() 493
Group by 198

H
Having 199
HTML Help Workshop 358

I
IGNORE NULL 219
Immediate 172
IN 432
Insert 206
Integer 173
IsNull() 263

J
Jpeg 43

L
Len() 263
LIKE 432
Long 173

M
Microsoft.ACE.OLEDB.12.0 311
Mid() 252
Move 345
MsgBox() 175

N
Now() 493

O
Object Explorer 411
Object Linking and Embedding 42
ODBC 256, 401
OLE 82
OLE DB 405
Option Explicit 174
Order by 197

651

R
Raise 266
RAISERROR 470
Recordset 344
RunSQL 280

S
Select 194
Selection 348
SET 428
Single 173
SOME 431
SQL Server 2005
Developer Edition 373
Enterprise Edition 373
Express Edition 374
Mobile Edition 374
Standard Edition 373
Workgroup Edition 373
SQL Server Management Studio 409
Static 171

T
Time() 493
Top 198
Transact-SQL 425
Trim() 253, 263

U
UNIQUE 219
Update 207

V
Visual Basic for Applications (VBA) 167

W
Where 196

652

153
20
:
- 20
- 20
379

() 19, 34
237
290
290, 296
290
153, 158

179
83

101
239
46
47
365
47
35, 220
19

295
220
:
448
448
30
179
"Office" 39
381
175
40
174
VBA 328
40

94

76
:
248
290
290

, 117
:
206
211
203

36

76
328
179, 180
79
224
162
187
:
20
20
20

230
20

405
21
:
- 33
30
23
31

38
20
:
Messages 417
171
:
If ... Theh 183
Select ...case 183
With 182
187
181
184
119
:
Shift 235
238
124
135

38
83
233
30
46
46
170
171

653

171
171
61
118
62
40
87
91
"" 93
259
381
102
454
:
DRI 388
392
:
240
241
82
25
387
30
VBA 188
364
190

159
69
540

82
162
:
-- 32
-- 32
-- 32
-- 32
152
76, 244

654

39
474
121
37
27
19
55
31, 246

21, 39
448
27
448
27
294
VBA 173
461, 475

236
:
51
53
378

78
67
68
112
292

108
74
69
73
104
70
:
VBA 190
178

458

76
57

251
388
- 64

SQL Server 377


79

DML 205

"-"
:
www.bhv.ru
" ": ., ., . 29, .: (812) 251-41-10
: e-mail: opt@bhv.spb.su


., . Visual Prolog
(+CD-ROM)

992 .

. . Microsoft Windows XP. Home Edition Professional.


640 .

. . Microsoft Windows 2000 Professional.

752 .

. . Microsoft Windows 2000 Server Professional.


1056 .

. . Microsoft Windows 2000 Server.

960 .

. . Microsoft Windows XP.

848 .

. Macromedia ColdFusion

672 .

. CorelDRAW 11

720 .

. CorelDRAW 12

720 .

1216 .

., ., . Microsoft Windows Server 2003.


1120 c.

. . Delphi 7

1216 c.

., . IntelliJ IDEA.
Java (+CD-ROM)

800 .

., . Microsoft Excel 2002

1072 .

., . Microsoft Excel 2003

1024 .

. Macromedia Dreamweaver MX

736 .

. Macromedia Dreamweaver MX 2004

736 .

. Macromedia Flash MX 2004

800 .

. Microsoft .NET (+CD-ROM)

704 c.

. HTML,

832 .

. .
. Mathcad 12
., . Microsoft Windows Server 2003
., . , 5- .
., . PHP 5
. ASP.NET
. Microsoft SQL Server 2000
. . HTML 4.0

1088 .
576 c.
1184 .
1152 c.
1120 .
992 .
1280 c.
672 .

. Microsoft Access 2003 (+CD-ROM)


., . Windows 98
. Java 2

1072 c.
592 .
1072 c.

. Web-, 2- .

1072 .

., . Microsoft Word 97

1120 .

- ., . XML

736 .

. AutoCAD 2004

976 .

. AutoCAD 2004.

624 .

. AutoCAD 2005

944 .

. FreeHand 7

320 .

. Adobe Illustrator CS

768 .

. Adobe Photoshop CS

928 c.

. WAP:

432 .

. Linux

912 .

. Linux, 2- .

944 .

. TCP/IP.

672 .

. Python (+CD-ROM)

768 .

. ., . . Adobe InDesign

704 .

. ., . . Adobe PageMaker 7.0

784 .

. ., . . CorelDRAW Graphics Suite 11:


. BIOS
. Turbo Pascal

1200 .
544 c.
1056 .

. Delphi

912 .

. CorelDRAW (+CD-ROM)

704 c.

. Qt. C++

544 .


Microsoft. Visual Basic 6.0
Microsoft. Microsoft Windows NT Server 4.0. 1 (+CD-ROM)

992 .
752 .

Microsoft. intranet. Microsoft

672 c.

Microsoft. . 2- (+CD-ROM)

368 .

. Dynamic HTML (+CD-ROM)

496 .

., . Access 97 (+CD-ROM)

656 .

384 .

. Linux (+CD-ROM)

496 .

. Windows

304 .

. -: , ,

256 .

. Windows 98 (+)

496 .

. Internet 2000

448 .

. Novell GroupWise 5.5:


480 .

. Excel, VBA, Internet

816 .

. Visual Basic .NET:

624 .

. Sound Forge.

384 .

. Windows (+)

384 .

., . Delphi, 2- .

624 .

. - CSS

544 c.

. . MS Excel (+)

304 .

. -

480 .

. Shareware:

320 .

. AutoCAD (+CD-ROM)

1168 .

. .

320 .

. . MATLAB 7. ,

752 .

. . - Delphi (+)

432 .

. Windows 2000

640 .

. Windows XP

560 .

. GTK+.
(+CD-ROM)

368 .

. DirectX. Delphi (+CD-ROM)

416 .

. OpenGL. Delphi (+)

352 .

. Java

336 .

. . Motorola

560 .

. -.

352 .

. . , ,

320 .

. Maple 6.

528 .

., . Visual C++ MFC, 2- . (+)

1040 .

., .

560 .

. Web- Microsoft Office 2000

320 .

. Microsoft Office 2000:

680 .

. . ,

624 .

2- .
. .

512 .

., . IP-

512 .

., . Cakewalk SONAR 4 Producer Edition.


(+CD-ROM)

600 .

., . Fruity Loops Studio: PC


(+CD-ROM)

368 c.

., .

496 .

. Visual LISP AutoCAD

576 .

. Adobe InDesign:

544 .

. Microsoft Office 2000: .


-
. (+CD-ROM)

512 .

., . .
(+CD-ROM)

432 c.

. .

352 .

., . 1C:. .

624 .

., . 1C:. .

320 .

., . 1:. .

304 .

., . 1:. .

368 .

., . 1:. .

352 c.

. SVGA- IBM

432 .

. Borland Kylix: (+CD-ROM)

544 .

. Open GL. , 2- .
(+)

304 .

. SQL Server 7.0:

370 .

. BIOS

400 .

. (+)

448 .

. Java 2

704 .

528 .

. Windows 2000 Active Directory

400 c.

. Java (+CD-ROM)

400 c.

. Web- Microsoft .NET

336 .

. -, 2- .

224 .

. Web-. XML

304 .

. ++

416 .

. SOFTIMAGE|XSI: (+CD-ROM)

432 .

. . , ,
(+CD-ROM)

464 .


. . Macromedia Flash MX 2004:

720 .

- ., - . Adobe Photoshop

592 .

., . Cubase SX (+CD-ROM)

640 .

., . Steinberg Nuendo 2.
(+CD-ROM)

432 .

., . (+CD-ROM)

496 .

., . Adobe Audition.
(+CD-ROM)

400 .

., . Cubase SX 2. (+CD-ROM)

656 .

., . Cubase Sonar
(+CD-ROM)

592 .

. AutoCAD:

288 .

. .

496 .

. :

320 .


. .
(+CD-ROM)

496 .

. C++ Pascal Kylix 3. -


544 .

. - Java

704 .

., . Java 2, Enterprise Edition.

1088 .

., . Delphi.
(+CD-ROM)

320 c.

. Microsoft Excel 2002:

768 .

., . Delphi 7 (+)

784 .

., . Web- Delphi
(+)

672 .

. - (+CD-ROM)

464 c.

. .

464 .

. . Windows-
(+CD-ROM)
. . MS Office XP:

544 .
944 .

C. . Microsoft ADO.NET:

768 .

., .

400 .

. SCSI IDE

592 .

. Windows, 2- .

656 .

. Visual C++ .NET

800 .

., .
Visual C++, 2- . (+CD-ROM)

560 .

. C++/C# Visual Studio .NET 2003

352 .

. Visual Studio. NET:

544 .

., .
Palm Pocket PC

352 .

. C++ Linux

368 .

. XML: Web- (+CD-ROM)

592 .

. Web- Java

400 .

. . Microsoft .NET Framework:

896 .

. :
(+)

384 .

. XML Web- Microsoft .NET


(+CD-ROM)

480 .


. . . , ,
(+CD-ROM)

336 .

. Excel, VBA C++


(+CD-ROM)

512 .

. -
(+CD-ROM)

368 .

. :

560 .

. Matlab 6.x:

672 .

. Microsoft Project

480 .

. MATLAB fuzzyTECH

736 .

., . . Crystal Reports

496 .

. (+CD-ROM)

464 .

. -3D
(+CD-ROM)
., . : , , 3- .

512 .
496 .

., .

542 .

. Mathcad Excel

464 .

. AutoCAD:

320 .


.
. Novell Netware 6/6.5 (+CD-ROM)

400 .
1056 .

. . , 2- .

368 .

. Microsoft Windows Server 2003

640 .

., .

752 .

. , 2- .

608 .

. Windows ScriptHost Windows 2000/XP (+)

640 .

., . FreeBSD: , ,

640 .

528 .


. OpenGL (+CD-ROM)

650 c.

. Delphi 2005

450 .

. MS Agent Speech API Delphi (+CD-ROM)

448 .

. OpenGL.
C++ (+CD-ROM)

736 .

. DirectX 9. C++ (+CD-ROM)

400 .

. MS Agent. (+CD-ROM)

352 .

. (+CD-ROM)

272 .

. MS Office Delphi
(+CD-ROM)

496 .

. . PHP 5. Web- (+CD-ROM)

960 .

. C++
(+CD-ROM)

496 .

384 .

. 1: 7.7/8.0:

336 .

. Windows (+CD-ROM)

880 .

. HTML Web-

400 .

. MS SQL Server 2000:

608 .

. STL C++

656 .

., . : GDI+ DirectX (+CD-ROM)

368 .

., . Delphi, 3- .

640 .

. ++

496 .


. USB.
(+CD-ROM)

576 c.

. PCI, PSI Express. , ,

416 .

. : , ,

320 .

384 .

. Linux

304 c.


. : ,

1200 .

464 .

. UNIX

800 c.

304 .

- . .

640 .

. Linux: , ,

288 .

. Linux (+CD-ROM)

480 .

. Windows 200 Windows Server 2003.



. Windows Vista.

1104 .
400 .

Оценить