microsoft access 2010 level iii - laguardia.edu

23
LaGuardia Community College 31-10 Thomson Ave, Long Island City, New York 11101 Created by ISMD’s Dept. Training Team. Microsoft Access 2010 Level III Handout Objectives I. Creating a Password Table II. Designing a Form III. Entering Codes Overview: With its Microsoft Office Fluent user interface and interactive design capabilities that do not require a deep database knowledge, Microsoft Office Access 2010 helps you track and report information with ease. I. Creating a Password Table 1. From the Access File Tab, Click Blank database enter the File name “Company Login Databaseand choose a location for storing the new database, Click Create.

Upload: truongthuan

Post on 05-Feb-2017

219 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: Microsoft Access 2010 Level III - laguardia.edu

LaGuardia Community College 31-10 Thomson Ave, Long Island City, New York 11101

Created by ISMD’s Dept. Training Team.

Microsoft Access 2010 Level III

Handout Objectives

I. Creating a Password Table

II. Designing a Form

III. Entering Codes

Overview: With its Microsoft Office Fluent user interface and interactive design capabilities that do not

require a deep database knowledge, Microsoft Office Access 2010 helps you track and report

information with ease.

I. Creating a Password Table

1. From the Access File Tab, Click Blank database enter the File name “Company Login

Database” and choose a location for storing the new database, Click Create.

Page 2: Microsoft Access 2010 Level III - laguardia.edu

2 | P a g e

2. Go to the Design View and save the table as Tbl_Employees

3. Add the following field names and corresponding Data Types

a. Employee ID – Auto Number

b. EmpName – Short Text

c. EmpPassword – Short Text

i. Go to Input Mask – Select Yes to Save

ii. Select Password – Finish

4. Go back to the Datasheet view and – Save.

5. Open the employees Table (Fill in entries) once done close table and Save.

d. Jack Smith - 11111

e. Jane Doe - 22222

f. Mary Cline - 33333

Page 3: Microsoft Access 2010 Level III - laguardia.edu

3 | P a g e

II. Designing a Form

1. Go to Create tab and select Form Design from the Forms Group

2. Go to the Design Tab and select Property Sheet from the Tools Group

Page 4: Microsoft Access 2010 Level III - laguardia.edu

4 | P a g e

3. In the Property sheet modify the Selection type

Form from in the Format Tab as follows:

a. Allow Datasheet View – No

b. Allow Layout View – No

c. Record Selectors – No

d. Navigation Buttons – No

e. Dividing Lines – Yes

f. Border Style – Dialog

Page 5: Microsoft Access 2010 Level III - laguardia.edu

5 | P a g e

g. Go to the Other tab in the property sheet and modify the Popup to Yes

4. Right Click on Form Grid and select Form Header / Footer

Page 6: Microsoft Access 2010 Level III - laguardia.edu

6 | P a g e

5. Increase the Form Header and Decrease the size of Form Footer.

6. Right Click in the Form Header and select from Fill/Back Color choose a Light Gray and repeat

the same steps for the Form Footer.

Page 7: Microsoft Access 2010 Level III - laguardia.edu

7 | P a g e

7. Go to the Controls group in the Design tab and select Label and place cursor in Form Heading

a. Type: Please Enter Password

b. Go to Format tab and change Font Color to Black

c. Increase the Font Size to 20

d. Right Click on Text go to Size and Select To Fit (Adjust Accordingly to grid)

Page 8: Microsoft Access 2010 Level III - laguardia.edu

8 | P a g e

8. Go to Design Tab and double click Button from the Controls group.

a. Drop and drag the Button in the Form Footer (Cancel the Wizard)

Page 9: Microsoft Access 2010 Level III - laguardia.edu

9 | P a g e

b. Copy the Button and paste next to the first button created.

i. Double Click the first button and select the Other tab in Property Sheet and

Change Name to cmdLogin

Page 10: Microsoft Access 2010 Level III - laguardia.edu

10 | P a g e

c. Double Click the Second button and rename to Exit

i. Select Other tab in Property Sheet

ii. Change Name to CmdExit

9. To Change the name of the buttons on the form simply double click the button and enter the

text &Login to the first button and &Exit to the second button.

Page 11: Microsoft Access 2010 Level III - laguardia.edu

11 | P a g e

10. Go to the Design Tab, click on Combobox from the Controls Group then Drag and Drop

into Detail Section

a. Select the First option in the Wizard (I want this com…) click Next

Page 12: Microsoft Access 2010 Level III - laguardia.edu

12 | P a g e

b. Make sure the Tables view option is selected and click Next

c. Click the > to add Employee ID & EmpName to Selected Fields section click Next

Page 13: Microsoft Access 2010 Level III - laguardia.edu

13 | P a g e

d. Select Employee Name as Ascending and click Next and Finish.

e. Click in the Unbound Section go to Other tab in Property Sheet and change name to

CboEmployeeName

Page 14: Microsoft Access 2010 Level III - laguardia.edu

14 | P a g e

f. Select the left most box (EmpName) and change font color to Black and Resize Boxes

Accordingly.

11. Go to the Design Tab, select Text Box from the Controls Group then drop and drag

into Details section

a. Click in the left text box and type in Password

b. Click in the Unbound Section go to Other tab in Property Sheet and change name to

TxtPassword.

Page 15: Microsoft Access 2010 Level III - laguardia.edu

15 | P a g e

c. Select the left most box (Password) and change font color to Black and Resize Boxes

Accordingly.

d. Close the Form (Right Click and Rename to FrmLogin)

OR =

=

12. Go to the Create Tab and Select Blank Form Design from the Forms group

Page 16: Microsoft Access 2010 Level III - laguardia.edu

16 | P a g e

a. Select Button from the Controls Group and drop into the center of the Form

and Click Cancel on the Wizard Box

b. Increase the Size and Rename Command0 to Welcome and click on design grid.

=

Page 17: Microsoft Access 2010 Level III - laguardia.edu

17 | P a g e

c. Close form and rename as MainForm press Ok

III. Entering Codes

13. Open frmLogin in the design view (Right Click and Select Design View)

a. Right click on the Login button and select Build Event….

Page 18: Microsoft Access 2010 Level III - laguardia.edu

18 | P a g e

b. Select Code Builder and OK it.

c. Select the Code from the Code Page and Copy the Codes from the Notepad File called

VBfrmlogincode.txt and paste to replace previous code.

Copy This Code

Page 19: Microsoft Access 2010 Level III - laguardia.edu

19 | P a g e

Paste Code here to replace then Save (Floppy) and Close (Red X)

Page 20: Microsoft Access 2010 Level III - laguardia.edu

20 | P a g e

d. Right click on the Exit Button Select Build Event

e. Select Code Builder and OK it

Page 21: Microsoft Access 2010 Level III - laguardia.edu

21 | P a g e

f. Type in doCmd.Quit in between Private Sub cmdExit_Click() and End Sub

g. Save and Test

Page 22: Microsoft Access 2010 Level III - laguardia.edu

22 | P a g e

VB CODE copy below and Paste.

Option Compare Database

Private intLogonAttempts As Integer

Private Sub cmdLogin_Click()

'Check to see if data is entered into the UserName combo box

If IsNull(Me.cboEmployeeName) Or Me.cboEmployeeName = "" Then

MsgBox "You must enter a User Name.", vbOKOnly, "Required Data"

Me.cboEmployeeName.SetFocus

Exit Sub

End If

'Check to see if data is entered into the password box

If IsNull(Me.txtPassword) Or Me.txtPassword = "" Then

MsgBox "You must enter a Password.", vbOKOnly, "Required Data"

Me.txtPassword.SetFocus

Exit Sub

End If

Page 23: Microsoft Access 2010 Level III - laguardia.edu

23 | P a g e

'Check value of password in tblEmployees to see if this matches value chosen in combo box

If Me.txtPassword.Value = DLookup("EmpPassword", "tbl_Employees", "[Employee ID]=" & Me.cboEmployeeName.Value) Then

MyEmpID = Me.cboEmployeeName.Value

'Close logon form and open splash screen

DoCmd.Close acForm, "frmLogin", acSaveNo

DoCmd.OpenForm "MainForm"

Else

MsgBox "Password Invalid. Please Try Again", vbCritical + vbOKOnly, "Invalid Entry!"

Me.txtPassword.SetFocus

End If

'If User Enters incorrect password 3 times database will shutdown

intLogonAttempts = intLogonAttempts + 1

If intLogonAttempts > 3 Then

MsgBox "You do not have access to this database. Please contact your system administrator.", vbCritical, "Restricted Access!"

Application.Quit

End If

End Sub

Private Sub FormFooter_Click()

End Sub