Hi all,
i have a form which has a button giving access to a restricted area. In the past to restrict users from entering it ive used the Environ Function in VB and it has always worked fine.
now i need to restrict everyone but three users so used the same code and amended it but it is not working:
The code:
If UserID <> "g.spicer" Then GoTo notvaliduser
takes you to an error message which kicks you out.
but despite being logged in as g.spicer it is still taking me to the notvaliduser and kicking me out.
So i tested it by adding this code:
If UserID = "g.spicer" Then GoTo greg (where greg is an error message: "user logged in as"&(UserId)"
and tells me i am in fact logged on as g.spicer.
Therefore when i remove that line of code why does it recognise me as g.spicer but take me to the notvaliduser anyway?
any ideas?
this works on my other forms and ive tried redoing the code and compacting and repairing but it is still not working.
The code in full:
Private Sub confnotes_Click()
On Error GoTo Err_confnotes_Click
Dim UserID As String
Dim stDocName As String
Dim stLinkCriteria As String
'get computer ans user details
UserID = Environ("USERNAME")
DoCmd.SetWarnings False
DoCmd.SetWarnings True
If UserID <> "g.spicer" Then GoTo notvaliduser
notvaliduser:
Call MsgBox("ACCESS DENIED. Only Senior Members of Teaching staff have access.", vbCritical, "Invalid User")
stDocName = "Confidential"
stLinkCriteria = "[StudentID]=" & "'" & Me![StudentID] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria, , acDialog
Exit_confnotes_Click:
Exit Sub
Err_confnotes_Click:
MsgBox Err.Description
Resume Exit_confnotes_Click
End Sub
i have a form which has a button giving access to a restricted area. In the past to restrict users from entering it ive used the Environ Function in VB and it has always worked fine.
now i need to restrict everyone but three users so used the same code and amended it but it is not working:
The code:
If UserID <> "g.spicer" Then GoTo notvaliduser
takes you to an error message which kicks you out.
but despite being logged in as g.spicer it is still taking me to the notvaliduser and kicking me out.
So i tested it by adding this code:
If UserID = "g.spicer" Then GoTo greg (where greg is an error message: "user logged in as"&(UserId)"
and tells me i am in fact logged on as g.spicer.
Therefore when i remove that line of code why does it recognise me as g.spicer but take me to the notvaliduser anyway?
any ideas?
this works on my other forms and ive tried redoing the code and compacting and repairing but it is still not working.
The code in full:
Private Sub confnotes_Click()
On Error GoTo Err_confnotes_Click
Dim UserID As String
Dim stDocName As String
Dim stLinkCriteria As String
'get computer ans user details
UserID = Environ("USERNAME")
DoCmd.SetWarnings False
DoCmd.SetWarnings True
If UserID <> "g.spicer" Then GoTo notvaliduser
notvaliduser:
Call MsgBox("ACCESS DENIED. Only Senior Members of Teaching staff have access.", vbCritical, "Invalid User")
stDocName = "Confidential"
stLinkCriteria = "[StudentID]=" & "'" & Me![StudentID] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria, , acDialog
Exit_confnotes_Click:
Exit Sub
Err_confnotes_Click:
MsgBox Err.Description
Resume Exit_confnotes_Click
End Sub