17.  Add the following command buttons to the Course Registration Form:

            Save

            Undo

            Return to the Student Screen

 

18.  Add the following command buttons to the Instructor Form:

            Save

            Undo

            Return to the Instructor Screen

 

19.    Create the following macro for the On Click property of the Enter button in the Login Screen: [AC 507-511]

 


20.    Create the following macro for the Instructor Screen:

 

 

21.  Create a similar macro as above for the Student Screen

 

 

 

22.  Create the following USER table:

            USER(UserName, Password, Type)

                        Where UserName = Student# if Type=student

                                    UserName = InstName if Type=instructor

 

23.  Create the corresponding menu bars and tool bars for each of these screens: Login, Instructor, and Student

            Login screen: Login & Quit

            Instructor/Student screen: Data Entry, View Report, & Return

                       

24.  Change the Startup properties in the University database so that

            Login screen will be opened automatically when the database opens:

 

           

 

25.  Convert the Login macro to VBA code:

            Tools à Macro à Convert Macros to Visual Basic


26.  Change the converted VBA code such that any user is allowed only 3 trials in entering their password:

           

(1)  Add the following declaration statement:

            Dim User As String

 

(2)  Replace the code for Password validation with the following:           

User = DLookup("[Password]", "USER", "[UserName]=Forms![Login]![UserName]")

            If ChkPwd(User) = 3 Then

                  Call FlagUser(Forms![login]![UserName])

                  Application.Quit

            End If

 

(3)  Type in the function ChkPwd:

Function ChkPwd(UserPD As String) As Integer

'To validate a user's password

 

Dim counter As Integer

Dim Pwd As String

 

counter = 1

Pwd = forms![Login]![Password]

Do While counter < 3

    If Pwd <> UserPD Then

        Pwd = InputBox("Invalid Password.  Please reenter")

        counter = counter + 1

    Else

        Exit Do

    End If

Loop

ChkPwd = counter

End Function

 

 

27.  Deactivate the user whenever his/her password has been invalidated:

 

(1)  Type in the subroutine FlagUser

Sub FlagUser(ID As String)

'A Subroutine to deactive a user

 

Dim db As Database

Dim rec As DAO.Recordset

Dim criterion As String

 

Set db = CurrentDb()

Set rec = db.OpenRecordset("USER")

rec.Index = "PrimaryKey"

rec.Seek "=", ID

rec.Edit

rec("Type") = "deactivated"

rec.Update

rec.Close

 

End Sub

 

(2)  Issue a message for a deactivated user:

        User = DLookup("[Type]", "USER", "[UserName]=Forms![Login]![UserName]")

        Select Case User

            Case "student"

                DoCmd.OpenForm "StudentSrn", acNormal, "", "", , acNormal

            Case "instructor"

                DoCmd.OpenForm "InsSrn", acNormal, "", "", acReadOnly, acNormal

            Case "deactivated"

                MsgBox "User Account is Deactivated.  Please see Administrator"

                Application.Quit

        End Select