Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Option Compare Database
- Dim rsUser As Recordset
- Private Sub CMDContact_Click()
- 'gives the user information to contact the booking system staff
- MsgBox ("Email Address: QinetiQ@yahoo.com" & vbCrLf & "Phonenumber: 0775839824" & vbCrLf & "Please only call during the hours of 8am to 8pm")
- End Sub
- Private Sub CMDExit_Click()
- 'closes the form
- DoCmd.Close
- DoCmd.OpenForm ("frmOpen")
- End Sub
- Private Function GenerateEmail()
- Dim AlphaChk As Integer
- Dim BaseNum As Integer
- Dim i As Integer
- 'makes the new password for the specified user
- 'and changes it for the user
- rsUser.FindFirst "U_EmailAddress = '" & Me.emailaddress & "'"
- Randomize Timer
- rsUser.Edit
- rsUser!U_Password = ""
- 'this makes a randomly genereated
- '5 character password
- For i = 1 To 5
- AlphaChk = (Rnd() * 2) + 0.5
- If AlphaChk = 1 Then
- BaseNum = (Rnd() * 26) + 95
- rsUser!U_Password = rsUser!U_Password + Chr(BaseNum)
- ElseIf AlphaChk = 2 Then
- BaseNum = (Rnd() * 9) + 0.5
- rsUser!U_Password = rsUser!U_Password + Str(BaseNum)
- End If
- Next i
- GenerateEmail = rsUser!U_Password
- rsUser!U_Password = Encrypt(rsUser!U_Password, 3)
- rsUser.Update
- End Function
- Private Sub cmdForgotPassword_Click()
- 'if the user forgets their password
- 'it asks for their email address
- MsgBox ("Please enter your email address")
- Me.emailaddress.Visible = True
- cmdSendNewPassword.Visible = True
- End Sub
- Private Sub cmdSendNewPassword_Click()
- 'if the users email address matches one in the table
- 'they send an email to that address with a new password
- rsUser.FindFirst "U_EmailAddress = '" & Me.emailaddress & "'"
- If rsUser.NoMatch Then
- MsgBox ("The Email Address does not exist, please type another in again")
- Else
- GenerateEmail
- 'send Email
- MsgBox ("an email has been send with a new password, please change your password when you login in the >Update< Account Section." & Decrypt(rsUser!U_Password, 3))
- End If
- End Sub
- Private Sub sendEmail()
- 'creates an instance of Outlook
- Set objOutlook = CreateObject("Outlook.application")
- Set objEmail = objOutlook.CreateItem(olMailItem)
- rsUser.FindFirst "U_Username = '" & Me.username & "'"
- 'creates and sends email
- With objEmail
- .To = email
- .Subject = U_username & "'s New Password "
- .Body = "Here is your new password; " & U_Password & " please change your password when you login in the >Update< Account Section."
- .Send
- End With
- 'closes outlook
- Set objEmail = Nothing
- objOutlook.Quit
- End Sub
- Private Sub CMDHelpOff_Click()
- 'turns help off
- Me.username.SetFocus
- Me.Helplabel1.Visible = False
- Me.Helplabel2.Visible = False
- Me.Helplabel3.Visible = False
- Me.Helplabel4.Visible = False
- Me.PasswordLabel.Visible = True
- Me.Usernamelabel.Visible = True
- cmdhelpoff.Visible = False
- cmdhelpon.Visible = True
- End Sub
- Private Sub CMDHelpOn_Click()
- 'turns help on
- Me.username.SetFocus
- Me.Helplabel1.Visible = True
- Me.Helplabel2.Visible = True
- Me.Helplabel3.Visible = True
- Me.Helplabel4.Visible = True
- Me.PasswordLabel.Visible = False
- Me.Usernamelabel.Visible = False
- cmdhelpon.Visible = False
- cmdhelpoff.Visible = True
- End Sub
- Private Sub CMDLogin_Click()
- rsUser.FindFirst "U_Username = '" & Me.username & "'"
- 'Searches for the entered Username
- If rsUser.NoMatch = True Then
- 'if there are no matching usernames display this message
- MsgBox "The Username you have entered does not exist", vbOKOnly, "Please Enter another Username" 'Displays this message when the wrong Username is entered
- Me.username.SetFocus
- ElseIf rsUser!U_AccountLocked = True Or rsUser!U_AccountVerified = False Then
- 'if the user tries access their account and is locked or not verified it will display this message
- MsgBox ("Your account is either locked or not verified, contact an admin for more info")
- Me.username.SetFocus
- ElseIf rsUser!U_Admin = True And rsUser!U_Password = Encrypt(Me.password, 3) And U_AccountLocked = False Then
- 'If the password matches with the Username password and is an admin then
- tempUserName = Me.username 'Takes the users username and uses it as the temp username
- tempName = rsUser!U_Firstname 'Takes the users firstname and uses it as the temp firsname
- tempID = rsUser!Staff_ID 'Takes the users staff id and uses it as the temp staff id
- tempSurname = rsUser!U_Surname 'Takes the users surname and uses it as the temp surname
- DoCmd.Close 'Closes form
- DoCmd.OpenForm "frmAdminMainMenu" 'Opens Main Menu form
- ElseIf rsUser!U_Password = Encrypt(Me.password, 3) And rsUser!U_AccountLocked = False And rsUser!U_AccountVerified = True Then
- 'If the password matches with the Username password and the account is not locked then
- tempUserName = Me.username 'Takes the users username and uses it as the temp username
- tempName = rsUser!U_Firstname 'Takes the users firstname and uses it as the temp firsname
- tempID = rsUser!Staff_ID 'Takes the users staff id and uses it as the temp staff id
- tempSurname = rsUser!U_Surname 'Takes the users surname and uses it as the temp surname
- DoCmd.Close 'Closes form
- DoCmd.OpenForm "frmMainMenu" 'Opens Main Menu form
- Else
- MsgBox "Wrong password and/or Username" 'Displays this message when the wrong password is entered
- Me.username.SetFocus
- End If
- End Sub
- Private Sub CMDRegister_Click()
- 'Closes the form and opens the new user form
- DoCmd.Close
- DoCmd.OpenForm ("frmNewUser")
- End Sub
- Private Sub Form_load()
- 'When the form loads set tbl user as rsuser
- Set rsUser = CurrentDb.OpenRecordset("tbluser", dbOpenDynaset)
- 'make these labels, buttons and text boxes invisible on form load
- Me.PasswordLabel.Visible = False
- Me.Usernamelabel.Visible = False
- Me.emailaddress.Visible = False
- cmdSendNewPassword.Visible = False
- cmdhelpon.Visible = False
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement