Hi all,
I have a basic table called tblUserTable which holds the following fields "UserName" and "Password". I then have a Login form called "frmLogin" which has the fields "UserName and "Password". On this form there is a button which has the following code in the On Click property.
Private Sub cmdOK_Click()
Dim strPassword As String
Static Tries As Integer
'Check to see if password is entered
If IsNull(Password) = True Then
MsgBox "Please enter your Password", , "No Password Entered"
Password.SetFocus
Exit Sub
Else
'Gets the Password stored in tblUserTable
strPassword = DLookup("Password", "tblUsertable", "[UserName]=forms!frmLogin!cboUserName")
End If
If Password = strPassword Then
DoCmd.Close
DoCmd.OpenForm ("frmMainPMS")
Else
MsgBox "The Password you have entered is incorrect.", , "Please enter it again."
Tries = Tries + 1
Password.SetFocus
End If
If Tries > 3 Then
MsgBox "You do not have access to this system" & Chr(13) & Chr(13) & "Please Contact your administrator", vbCritical, "Restricted Access!"
DoCmd.Close
End If
End Sub
What I want to be able to do is once the user has logged in succesfully there needs to be a field on the form "frmMainPMS" which shows the name of the user (UserName from tblUsername)logged in.
Any help anybody could give me with this would be much appreciated.
Thanks,
Steven. C.
I have a basic table called tblUserTable which holds the following fields "UserName" and "Password". I then have a Login form called "frmLogin" which has the fields "UserName and "Password". On this form there is a button which has the following code in the On Click property.
Private Sub cmdOK_Click()
Dim strPassword As String
Static Tries As Integer
'Check to see if password is entered
If IsNull(Password) = True Then
MsgBox "Please enter your Password", , "No Password Entered"
Password.SetFocus
Exit Sub
Else
'Gets the Password stored in tblUserTable
strPassword = DLookup("Password", "tblUsertable", "[UserName]=forms!frmLogin!cboUserName")
End If
If Password = strPassword Then
DoCmd.Close
DoCmd.OpenForm ("frmMainPMS")
Else
MsgBox "The Password you have entered is incorrect.", , "Please enter it again."
Tries = Tries + 1
Password.SetFocus
End If
If Tries > 3 Then
MsgBox "You do not have access to this system" & Chr(13) & Chr(13) & "Please Contact your administrator", vbCritical, "Restricted Access!"
DoCmd.Close
End If
End Sub
What I want to be able to do is once the user has logged in succesfully there needs to be a field on the form "frmMainPMS" which shows the name of the user (UserName from tblUsername)logged in.
Any help anybody could give me with this would be much appreciated.
Thanks,
Steven. C.