padlocked17
Registered User.
- Local time
- Today, 15:51
- Joined
- Aug 29, 2007
- Messages
- 276
Alrighty -
After learning that 2007 has no User Security roles, and not having Sharepoint or a SQL server, I decided to work starting with Bob's Simple Login script located here.
I've got it functioning fine and incorporated some of the options also made available here.
You'll see the code below used to store info in a hidden form that is holding the username and permissions level. I'm looking to try and store this information into a global variable instead of a hidden table.
I know that I could define it as a variable right here in the code, but how do I define it as a Global variable so I can use it later in the application in the VBA?
After learning that 2007 has no User Security roles, and not having Sharepoint or a SQL server, I decided to work starting with Bob's Simple Login script located here.
I've got it functioning fine and incorporated some of the options also made available here.
You'll see the code below used to store info in a hidden form that is holding the username and permissions level. I'm looking to try and store this information into a global variable instead of a hidden table.
I know that I could define it as a variable right here in the code, but how do I define it as a Global variable so I can use it later in the application in the VBA?
Code:
Private Sub cmdLogin_Click()
Dim strUser As String
Dim strPWD As String
Dim intUSL As Integer
strUser = Me.txtUser
If DCount("[UserPWD]", "tblUsers", "[UserName]='" & Me.txtUser & "'") > 0 Then
strPWD = DLookup("[UserPWD]", "tblUsers", "[UserName]='" & Me.txtUser & "'")
If strPWD = Me.txtPwd Then
intUSL = DLookup("[SecurityGroup]", "tblUsers", "[UserName]='" & Me.txtUser & "'")
[COLOR="Red"] Forms!frmUSL.txtUN = strUser
Forms!frmUSL.txtUSL = intUSL[/COLOR]
Select Case intUSL
Case 1
DoCmd.OpenForm "frmHome", acNormal
Case 2
DoCmd.OpenForm "frmHome", acNormal, , , acFormReadOnly
Case 3
MsgBox "Not configured yet", vbExclamation, "Not configured"
Case 4
MsgBox "Not configured yet", vbExclamation, "Not configured"
End Select
DoCmd.Close acForm, "frmLogin", acSaveNo
Else
If MsgBox("You entered an incorrect password" & vbCrLf & _
"Would you like to re-end your password?", vbQuestion + vbYesNo, "Restricted Access") = vbYes Then
Me.txtPwd.Value = ""
Counter = Counter + 1
If Counter = DLookup("[OptionValueNum]", "tblOptions", "[OptionsID]=1") Then
MsgBox "You have entered an incorrect password too many times. This database will now close!", vbCritical, "Wrong password!"
DoCmd.Quit
End If
Else
DoCmd.Quit
End If
End If
End If
End Sub