G
Guest
Hello, I want to be able to check the users PC login name on a "WelcomeForm"
against a field named loginID with names and if the users PC login name isnt
in the list in the table "tbl_LoginID" then they get a message stating they
do not have access to the database and the database closes. I already have a
"WelcomeForm" startup form that shows the users login name by using a test
box named Text_Network_User and its default value =FOSUserName() and a module
that gets the users login name andputs it in the Text_Network_User . That
works great! my problem is I want to run code on the "WelcomeForm" on open
event that would check the name thats in the Text_Network_User text box and
if its not in the tbl_LoginID field- LoginID then it closes the database.
Here is what I have so far and it keeps closing the database... Im a newbie
so please expalin... Thanks!
Private Sub Form_Open(Cancel As Integer)
'Check value of password in tblEmployees to see if this matches value chosen
in combo box
If Me.Text_Network_User.Value = DLookup("LoginID", "tbl_LoginID") Then
LoginID = Me.Text_Network_User.Value
'Close logon form and open Welcome screen
DoCmd.OpenForm "WelcomeForm"
Else
MsgBox "Access Denyed", vbOKOnly, "Invalid Entry!"
End If
Application.Quit
End Sub
against a field named loginID with names and if the users PC login name isnt
in the list in the table "tbl_LoginID" then they get a message stating they
do not have access to the database and the database closes. I already have a
"WelcomeForm" startup form that shows the users login name by using a test
box named Text_Network_User and its default value =FOSUserName() and a module
that gets the users login name andputs it in the Text_Network_User . That
works great! my problem is I want to run code on the "WelcomeForm" on open
event that would check the name thats in the Text_Network_User text box and
if its not in the tbl_LoginID field- LoginID then it closes the database.
Here is what I have so far and it keeps closing the database... Im a newbie
so please expalin... Thanks!
Private Sub Form_Open(Cancel As Integer)
'Check value of password in tblEmployees to see if this matches value chosen
in combo box
If Me.Text_Network_User.Value = DLookup("LoginID", "tbl_LoginID") Then
LoginID = Me.Text_Network_User.Value
'Close logon form and open Welcome screen
DoCmd.OpenForm "WelcomeForm"
Else
MsgBox "Access Denyed", vbOKOnly, "Invalid Entry!"
End If
Application.Quit
End Sub