Re: Permission to open database



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.........



.



Relevant Pages

  • Re: Permission to open database
    ... Private Sub Form_Open ... "Please contact the Database Adminstrator for assistance.", ... Dim rst As DAO.Recordset ... "WelcomeForm" ...
    (microsoft.public.access.gettingstarted)
  • Re: Please Help me....RE: Importing Word into Access 2000. Please
    ... so it will work in my real database. ... Dim appWord As Word.Application ... Set appWord = GetObject ... "John Nurick" wrote: ...
    (microsoft.public.access.externaldata)
  • Re: transferdatabase error
    ... Thanks John. ... >> I am using the following code to transfer database objects to a new ... >> Dim ws As Workspace ... >> 'Path and file name for new mdb file ...
    (microsoft.public.access.formscoding)
  • Re: Opening ADO.Recordsets
    ... Thanks Ron. ... they were optional when working in the same database. ... >> Dim strQuery As String ... >> John H W ...
    (microsoft.public.access.formscoding)
  • Re: Is This Possible ... ? Yes - Upload images to an Access database
    ... It looks like your databases folder is outside the root of your web ... I created a database exactly as you said, the only change I made was to ... and underneath an 'upload' button and a 'view images' button. ... Dim con As New Data.OleDb.OleDbConnection ...
    (microsoft.public.dotnet.framework.aspnet)