Re: Permission to open database
- From: Chad <Chad@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Thu, 13 Sep 2007 06:30:02 -0700
John I got it to work with the code below I got from an example I found. I
would also like to add an outlook window with my email address so they can
email me. I posted this question in the new users so it wouldnt get mixed up
with this one. Please look at it because I havent a clue on how to go about
implimenting this... Thanks!
Private Sub Form_Open(Cancel As Integer)
Dim db As DAO.Database
Dim rst As DAO.Recordset
Dim rstV As Recordset
Dim stDocName As String
Dim stLinkCriteria As String
Set db = CurrentDb()
Set rst = db.OpenRecordset("tbl_LoginID", dbOpenDynaset)
If Not IsNull(Me.Text_Network_User) Then
rst.FindFirst "strEmployeeUserID = '" & Me.Text_Network_User & "'" &
" And strEmployeeUserID = '" & Me.Text_Network_User & "'"
If rst.NoMatch Then
MsgBox "You do not have access to this database!!! " & Chr(13) & _
"Please contact the Database Adminstrator for assistance.",
vbOKOnly + vbCritical, "Logon Denied"
DoCmd.Quit
Else
stDocName = "WelcomeForm"
DoCmd.OpenForm stDocName, , , stLinkCriteria
End If
End If
End Sub
--
Newbies need extra loven.........
"John Spencer" wrote:
Probably because you copied it and it was wrapped into multiple lines by the.
newsreader. Plus Klaatu missed a closing parentheses.
If IsNull(DLookup("[loginID]", _
"[tbl_LoginID]", _
"[loginID] = '" & Me.Text_Network_User & "'")) Then
MsgBox "You are Not Authorized to Live on This Planet"
End If
Although my preference is this situation is to use DCount instead of
DLookup.
If DCount("*","tblLoginID","LoginID = '" & Me.Text_Network_User & "'") = 0
Then
MsgBox "Go home. You are wanted here."
End If
The above should be three lines of code. The first line starts with "IF"
and ends with "Then"
--
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
..
"Chad" <Chad@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:0F1DD6E4-08AA-4FE3-A999-46000FC9A74B@xxxxxxxxxxxxxxxx
I forgot to mention I cant even ener this code it gives me a error
Compile error:
Expected: expression
--
Newbies need extra loven.........
"Klatuu" wrote:
If IsNull(DLookup("[loginID]", "[tbl_LoginID]", "[loginID] = '" &
Me.Text_Network_User & "'" Then
MsgBox "You are Not Authorized to Live on This Planet"
End If
--
Dave Hargis, Microsoft Access MVP
"Chad" wrote:
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
--
Newbies need extra loven.........
- Follow-Ups:
- Re: Permission to open database
- From: Klatuu
- Re: Permission to open database
- References:
- Re: Permission to open database
- From: John Spencer
- Re: Permission to open database
- Prev by Date: Re: Repeat data input within forms, Access 2003
- Next by Date: Re: Permission to open database
- Previous by thread: Re: Permission to open database
- Next by thread: Re: Permission to open database
- Index(es):
Relevant Pages
|