Title: BAA3032: Week 17
1BAA3032 Week 1-7
2BAA3032 Week 9-15
3- Assalamualaikum wbt
- / Good day
4Last week practice
- Learn to create form that has buttons for record
operation, record navigation form operation. - Learn to create table, relationship and form for
1-to-many records relationship. - REMINDER TEST NO.1 WEEK 6 PROJECT BASED ON
TABLE DEFINATION, FORM DEFINATION, RELATIONSHIP. - Every screen when creating form/table/relationship
is important to understand. - Project Assign in Week 4 after customization and
due in week 6.
5Lessons for Week 3
- Learn to create table, relationship and form for
1-to-1 records relationship. - Learn to create table, relationship and form for
many-to-many record relationship.
6Lesson 1 - Lecture 1
- Learn to create table, relationship and form for
1-to-1 record relationship.
7Target Skills
- To create 1-to-1 records data entry form.
Scenario When there sensitive info. Or may add
other data later and not touch the current info.
8The Steps
- Create table Bank Account
- Create relationship 1-1 link between table
Project and table Bank Account. - Create form Form Bank Account - type columnar.
9The Table
10The Relationship
11The Form
12Lessons for Week 3
- Learn to create table, relationship and form for
1-to-1 records relationship. - Learn to create table, relationship and form for
many-to-many record relationship.
13Lesson 2 - Lecture 2
- Learn to create table, relationship and form for
many-to-many record relationship.
14Target Skills
- To create many-to-many records data entry form.
15Target Skills
- To create many-to-many records data entry form.
16Table Consultants
17Table Projects
18The Steps
- Create table PNC(Assume Created table
Consultant) - Create relationship 1-to-many between table
Projects and table PNC1. - Create relationship 1-to-many between table
Consultants and table PNC1. - Create form based on table Projects, PNC and
Consultants.
19The Table
20The Table
21The Relationship
22The Form
23The Form
24Additional combobox
25Practice Week 4
- Create table, relationship and form for 1-to-1
records relationship. - Project Information Bank Account
- Consultants Status
- Staffs Password and Picture
- Inventory Location and Picture
- Create table, relationship and form for
many-to-many records relationship. - Project Information Consultants
- Project Information Staffs
- Inventory Suppliers
26 27Last week practice
- Learn to create table, relationship and form for
1-to-1 records relationship. - Learn to create table, relationship and form for
many-to-many records relationship.
28Lessons for Week 4
- Learn to customized - create menu system, create
form links and customized form. - Learn to customized - create menu system, create
form links and customized form.
29Lesson 1 - Lecture 1
- Learn to customized - create menu system, create
form links and customized form.
30Target Skills
- To customized forms and create the information
system. - Project Listing
- Project Information
- Payments
- Bank Account
- Find
- Filter
- Close / Quit
- Consultants / Local Authority etc..
- Menu
- Startup
31Built Event On Load DoCmd.Maximize
Popup True Modal True Allow additions
False Navigation buttons False
32Properties
- List of form properties to be customized.
- Popup no menu
- Modal require close it to switch to other
windows. - Record selectors hide record arrow
- Navigation buttons
- Scrollbars
- Allow additions
- Allow edits
- Event on load Docmd.maximize
- Text box properties
- Enabled
- Locked
33- Combo box require create table.
Record selector
Navigation buttons
34Enabled ? Locked ? For text box
Allow additions
35(No Transcript)
36(No Transcript)
37 MyI InputBox("Enter state ('reset to all
states'", , "") If MyI "" Then Exit Sub
If MyI "" Then Me.FilterOn
False Else Me.Filter "State '"
MyI "'" Me.FilterOn True End If
38Validation
- Private Sub VALUE_BeforeUpdate(Cancel As Integer)
- If VALUE.VALUE lt 1000 Then
- MsgBox Is it number less than 1,000.00
- CancelTrue
- End If
- End Sub
- Private Sub END_DATE_BeforeUpdate(Cancel As
Integer) - If END_DATE lt START_DATE Then
- MsgBox "Date less than start date?"
- Cancel True
- End If
- End Sub
39Calculated Fields
- 1. Add field in table Tax
- 2. Add field in form Tax
- 3. Add code
- Private Sub VALUE_AfterUpdate()
- TAX.VALUE VALUE.VALUE
- End Sub
40- Dim MyT1, MyT2 as String
- Private Sub Text2_AfterUpdate()
- MyT1 Text2.Text
- End Sub
- Private Sub Text4_AfterUpdate()
- MyT2 Text4.Text
- End Sub
- Private Sub Command0_click()
- Dim MyDb As Database
- Dim MyRs As Recordset
-
- Set MyDb CurrentDb
- Set MyRs MyDb.OpenRecordset("SELECT FROM
Users WHERE Username '" MyT1 "' and
Password '" MyT2 "'") - If MyRs.RecordCount 0 Then
- MsgBox "Wrong username or password"
- End If
41Menu Tools / startup
42Practice Week 5
- Recreate form shown in week 4
- Create information system for-
- Consultants
- Inventory
- Daily Reports
- Staffs
43Project No.1
- Create Project Information System. Link related
tables below. - Projects
- Payment Details
- Progress Details
- Bank Account
- Staffs
- Consultants
- Inventory
- Create Information System that has form based on
single records, 1-1, 1-many, many-many
relationship. Project based on your selection.
44Project No.1
- Create Project Information System. Link related
tables below. (5) - Projects
- Payment Details
- Progress Details
- Bank Account
- Internal Staffs
- Consultants - Staffs
- Inventory Received Consumed
- Create Information System that has form based on
single records, 1-1, 1-many, many-many
relationship. Project based on your selection.
Show relationship and flow of information. (5) - 1) Bank Accounts 2) Students Info 3) Staffs info
4) Library system 5) Faculties 6) Sales 7)
Minute of Meeting 8) Water Bills 9) Phone Bills
10) Electric Bills 11) Monthly Spending 12)
BAA3032 Markings 13) List of Hotels 14) List of
Restaurants 15) List of Universities 16) List of
Journals 17) List of Letters in/out 18) Site
Daily Reports 19) Cars Registration Info. 20)
Pipe Information System
45 46Last week practice
- Recreate form shown in week 4
- Create information system for-
- Consultants
- Inventory
- Daily Reports
- Staffs
47Lessons for Week 5
- Introduction to SQL
- SQL Data Retrieval
- SELECT, WHERE, ORDER BY
- WHERE String, Numbers, Date, Logical AND, OR,
NOT. - SQL Data Summary (Aggregate functions)
- SQL Data Manipulation
48Lesson 12 - Lecture 1
- Introduction to SQL
- SQL Data Retrieval
- SELECT, WHERE, ORDER BY
- WHERE String, Numbers, Date, Logical AND, OR,
NOT.
49SQL
- SQL (commonly expanded to Structured Query
Language see History for the term's derivation)
is the most popular computer language used to
create, modify, retrieve and manipulate data from
relational database management systems.
50SQL Data Retrieval
- SELECT is used to retrieve zero or more rows from
one or more tables in a database. In most
applications, SELECT is the most commonly used
Data Manipulation Language command. In specifying
a SELECT query, the user specifies a description
of the desired result set, but they do not
specify what physical operations must be executed
to produce that result set. Translating the query
into an efficient query plan is left to the
database system, more specifically to the query
optimizer. - Commonly available keywords related to SELECT
include - FROM is used to indicate from which tables the
data is to be taken, as well as how the tables
join to each other. - WHERE is used to identify which rows to be
retrieved - ORDER BY is used to identify which columns are
used to sort the resulting data.
51SQL Data Retrieval - general
- SELECT FROM PROJECTS
- WHERE STATE 'MELAKA' ORDER BY 'File No'
- Me.RecordSource "SELECT FROM PROJECTS
- WHERE STATE 'MELAKA' Order by File No"
- This example retrieves the records from the
projects table that have a state field which is
equal to Melaka. The result is sorted
alphabetically by File No. The asterisk () means
to show all columns of the projects table.
Alternatively, specific columns could be named.
52(No Transcript)
53SQL Data Retrieval - string
- SELECT FROM PROJECTS
- WHERE STATE 'MELAKA' ORDER BY 'File No'
- Me.RecordSource "SELECT FROM PROJECTS
- WHERE STATE 'MELAKA' Order by File No"
- VARIABLE AS PART OF SQL STRING
- MyI Inputbox(Type in state)
- If MyI then Exit sub
- Me.RecordSource "SELECT FROM PROJECTS
- WHERE STATE MyI ' Order by File No"
54SQL Data Retrieval - string
- Asterisk is for pattern matching.
- SELECT FROM PROJECTS
- WHERE STATE LIKE P' ORDER BY 'File No'
- Asterisk is for pattern matching.SELECT FROM
PROJECTS - WHERE STATE LIKE K' ORDER BY 'File No'
55SQL Data Retrieval - Numbers
- SELECT FROM PROJECTS
- WHERE VALUE gt 10000 ORDER BY 'File No'
- Me.RecordSource "SELECT FROM PROJECTS
- WHERE VALUE gt 1000 Order by File No"
- VARIABLE AS PART OF SQL STRING
- MyI Inputbox(Type in VALUE)
- If MyI then Exit sub
- Me.RecordSource "SELECT FROM PROJECTS
- WHERE VALUE gt MyI Order by File No"
56SQL Data Retrieval - Date
- SELECT FROM PROJECTS
- WHERE End Date gt 1-JUL-2006 ORDER BY 'File
No' - Me.RecordSource "SELECT
- FROM PROJECTS
- WHERE START DATEgt1/13/2006
- VARIABLE AS PART OF SQL STRING
- MyI Inputbox(Type in VALUE)
- If MyI then Exit sub
- Me.RecordSource "SELECT FROM PROJECTS
- WHERE START DATEgt MyI Order by File
No"
57SQL Data Retrieval Logical - AND
- SELECT FROM PROJECTS
- WHERE STATE 'MELAKA' AND
- VALUE gt 1000 ORDER BY 'File No'
- SELECT FROM PROJECTS
- WHERE STATE 'MELAKA AND
- End Date gt 1-JUL-2006 ORDER BY 'File No
58SQL Data Retrieval Logical - OR
- SELECT FROM PROJECTS
- WHERE STATE 'MELAKA' OR
- STATE PERLIS' ORDER BY 'File No'
- SELECT FROM PROJECTS
- WHERE STATE 'MELAKA and End Date gt
1-JUL-2006 ORDER BY 'File No
59SQL Data Retrieval Logical - NOT
- SELECT FROM PROJECTS
- WHERE NOT STATE 'MELAKA'
- ORDER BY 'File No
- SELECT FROM PROJECTS
- WHERE NOT (STATE 'MELAKA' AND
- VALUE gt 1000) ORDER BY 'File No'
60SQL Data Retrieval Order by
- SELECT FROM PROJECTS
- ORDER BY STATE ASC
- SELECT FROM PROJECTS
- ORDER BY VALUE
- SELECT FROM PROJECTS
- ORDER BY STATE, VALUE
- --------------------------------------------------
----------------------------------------- - SELECT FROM PROJECTS
- ORDER BY VALUE ASC
- SELECT FROM PROJECTS
- ORDER BY VALUE DESC
- SELECT FROM PROJECTS
- ORDER BY STATE ASC, VALUE DESC
61Lessons for Week 5
- Introduction to SQL
- SQL Data Retrieval
- SELECT, WHERE, ORDER BY
- WHERE String, Numbers, Date, Logical AND, OR,
NOT. - SQL Data Summary (Aggregate functions)
- SQL Data Manipulation
62Lesson 34 - Lecture 2
- SQL Data Summary (Aggregate functions)
- SQL Data Manipulation
63SQL Data Summary
- SQL Aggregate Functions
- Using the SQL aggregate functions, you can
determine various statistics on sets of values.
You can use these functions in a query and
aggregate expressions in the SQL property of a
QueryDef object or when creating a Recordset
object based on an SQL query. - Avg Function
- Count Function
- First, Last Functions
- Min, Max Functions
- StDev, StDevP Functions
- Sum Function
- Var, VarP Functions
64SQL Data Summary Sum
- SELECT SUM(VALUE) AS JUM
- FROM PROJECTS
65SQL Data Summary Sum
- Dim MyDB As Database
- Dim MyRs As Recordset
- Set MyDB CurrentDb
- Set MyRs MyDB.OpenRecordset("SELECT Sum(Value)
as Jum FROM PROJECTS") - MsgBox MyRs(Jum")
-
- MyRs.Close
- MyDB.Close
66SQL Data Summary Sum
- SELECT SUM(VALUE) AS JUMKONTRAK FROM PROJECTS
- SELECT COUNT(VALUE) AS BILKONTRAK FROM PROJECTS
- SELECT SUM(VALUE) AS JUMKONTRAK, COUNT(VALUE) AS
BILKONTRAK FROM PROJECTS
67SQL Data Summary Sum where
- SELECT SUM(VALUE) AS JUMKONTRAK FROM PROJECTS
WHERE STATE MELAKA - SELECT COUNT(VALUE) AS BILKONTRAK FROM PROJECTS
WHERE STATE MELAKA - SELECT SUM(VALUE) AS JUMKONTRAK, COUNT(VALUE) AS
BILKONTRAK FROM PROJECTS WHERE STATE MELAKA
68SQL Data Summary Sum
- SELECT COUNT(VALUE) AS BILKONTRAK,SUM(VALUE) AS
JUMKONTRAK , MAX (VALUE) AS MAKKONTRAK,
MIN(VALUE) AS MINKONTRAK FROM PROJECTS
69Lessons for Week 6
- Test No.1
- Review Test No.1
70Lessons for Week 7
- SQL Data Manipulation
- Update
- Delete
- Insert
- Reports
- Listing
- Listing with summary
- Group Listing
- Group Listing with summary
- Group Listing with summary grand summary.
71SQL Data Manipulation - Update
- Creates an update query that changes values in
fields in a specified table based on specified
criteria. - Syntax
- UPDATE table   SET newvalue  WHERE criteria
- UPDATE is especially useful when you want to
change many records or when the records that you
want to change are in multiple tables. - You can change several fields at the same time.
The following example increases the Order Amount
values by 10 percent and the Freight values by 3
percent for shippers in the United Kingdom - UPDATE PROJECTSSET TAX VALUE 0.1,UPDATED
1-JUL-2006WHERE ShipCountry 'UK'
72SQL Data Manipulation - Update
- UPDATE PROJECTSSET TAX VALUE 0.1
- UPDATE PROJECTS SET TAX VALUE 0.2
- WHERE State Melaka
- UPDATE PROJECTS SET TAX VALUE 0.3
- WHERE ID 5
73SQL Data Manipulation - Update
- Dim MyDB As Database
- Dim MyRs As Recordset
- Set MyDB CurrentDb
- MyDB.Execute (UPDATE PROJECTS SET TAX VALUE
.2") -
- MyRs.Close
- MyDB.Close
74SQL Data Manipulation - Update
- UPDATE PROJECTSSET TAX VALUE 0.1
- UPDATE PROJECTSSET TAX VALUE 0.2,UPDATED
1-JUL-2006 - UPDATE PROJECTSSET TAX VALUE 0.3,UPDATED
7-JUL-2006 - WHERE STATE MELAKA
- UPDATE PROJECTSSET STATUS BIDDING PROCESS
WHERE STATUS PRE-CONSTRUCTION
75SQL Data Manipulation Delete
- Creates a delete query that removes records from
one or more of the tables listed in the FROM
clause that satisfy the WHERE clause. - Syntax
- DELETE table. Â FROM table WHERE criteria
76SQL Data Manipulation - Update
- DELETE FROM PROJECTSWHERE ID 4
- DELETE FROM PROJECTSWHERE State Pahang
77SQL Data Manipulation - Update
- Dim MyDB As Database
- Dim MyRs As Recordset
- Set MyDB CurrentDb
- MyDB.Execute (UPDATE PROJECTS SET TAX VALUE
.2") -
- MyRs.Close
- MyDB.Close
78Practice Week 8
- Recreate commands using SQL as shown in week 7
- Create commands using SQL as shown in week 7 for
1-1 form Project Payments
79 80Lessons for Week 7
- SQL Data Manipulation
- Update
- Delete
- Insert
- Reports
- Listing
- Listing with summary
- Group Listing
- Group Listing with summary
- Group Listing with summary grand summary.
- Fields can be sorted
81General Listing
82General Listing
83General Listing with Summary
84General Listing with Summary
85By Group
86By Group
87By Group with summary
88By Group with summary
89By Group with grand summary
90By Group with grand summary
91Week 9 Database Programming
- Object Database
- Property Recordsource
- Object Recordset
- Action Movefirst
- Action MoveLast
- Action MoveNext
- Action MovePreviousAction AddnewAction
Delete - Property BOF
- Property EOF
- Property Recordcount
92Database Programming
- Me.Recordsource SELECT FROM PROJECTS
- To move record to first row/record.The action ?
Movefirst - Me.Recordset.MoveFirst
- To move record to first row/record.The action ?
Movefirst - Me.Recordset.MoveLast
93Database Programming
- To move record to next row/record.The action ?
Movefirst - Me.Recordset.MoveNext
- To move record to previous row/record.The action
? MovePrevious - Me.Recordset.MovePrevious
94Database Programming
- To check if cursor is past the last records. The
property ? EOF - Me.Recordset.MoveNext
- If Me.Recordset.EOF then Me.Recordset.MoveLast
- To check if cursor is before the first records.
The property ? BOF - Me.Recordset.MovePrevious
- If Me.Recordset.BOF then Me.Recordset.MoveFirst
95Database Programming
- To add a record.The action ? Addnew
- Me.Recordset.Addnew
- To delete a record.The action ? Delete
- Me.Recordset.Delete
- To check number of recordThe property
Recordcount - If Me.Recordset.Recordcount gt 0 then
Me.Recordset.Delete