aron.ridgway
Registered User.
- Local time
- Today, 09:36
- Joined
- Apr 1, 2014
- Messages
- 148
i have the following code that compares the environ username with the username. I need to adapt it so it looks at and compares the Username Sting and finds the ID for that field? thanks
Code:
Private Sub Form_Open(Cancel As Integer)
If DCount("*", "tblUser", "userName = '" & Environ("username") & "'") = 0 Then
MsgBox Environ("username") & " You do not have access to the DataBase, please contact the Admin.", vbCritical, "NO ACCESS !"
Cancel = True
Else
'Me.lblUserName.Caption = Environ("Username")
End If
Dim rsO As DAO.Recordset
Set rsO = CurrentDb.OpenRecordset("SELECT Companyname, Permission FROM tblUserPermission WHERE Username = '" & Me.txtName.Value & "'")
Do While Not rsO.EOF
Select Case rsO.Fields("Companyname")
Case "Rothschild Waddesdon Ltd"
Me.btnRWL.Visible = rsO.Fields("Permission")
Case "Five Arrows Hotel"
Me.btnFAH.Visible = rsO.Fields("Permission")
Case "Rothschild Foundation Grants"
Me.btnRFG.Visible = rsO.Fields("Permission")
Case "Rothschild Foundation Property"
Me.btnRFP.Visible = rsO.Fields("Permission")
Case "Rothschild Foundation Waddesdon"
Me.btnRFW.Visible = rsO.Fields("Permission")
End Select
rsO.MoveNext
Loop
Set rsO = Nothing
End Sub