Do not Open Form, need to login

SBBmaster09

Registered User.
Local time
Tomorrow, 02:00
Joined
Apr 26, 2013
Messages
92
I have a form that can be accessed once I login. So I have the code

Code:
 Me.txtEID.Value = LCase(Forms!frm_Main!CurrentUser)

to call the textfield from the other form. I have 2 forms, the Main and the Roster. I need to login in Main so I can access the Roster. The thing is when I click the Roster, and not yet logging in, it will prompt "User Login Required!".

So I have this code

Code:
 If IsNull(Forms!frm_Main!CurrentUser) Then
    MsgBox "User Login Required!", vbExclamation, "User Not Logged In"
Else
    Me.txtEID.Value = LCase(Forms!frm_Main!CurrentUser)
End If

But when I open the roster it gives me an error (See attached)

Is it possible, when I click Ok it will just disappear and the Roster form will not open.
 

Attachments

  • Login.PNG
    Login.PNG
    8.6 KB · Views: 136
you could put docmd.close after your msgbox
 
I already tried this but still has error.
 
Depending on the version of Access, a form might not be in the Forms collection until it is open, in which case a reference to a control on that form will not be found.

At my site, we take this approach:

First, we have a domain-based login on our workstations. In that login, you have to supply a username and password. If you DO, you have an environmental value that is your network user name.

So I capture that name - but if you somehow got there without logging in, your name will not be what I have stored in my user table. If your name IS in my user table, I let you in because I have an implied trust of the domain. Look at the Environ function to see what you can pull in the way of environmental values. Talk to your domain administrator (if you have one) to see what level of trust you can place in the login name.

Obviously, this won't work if you allow one person to log in under more than one name. But if you have a "one user/one login" environment, don't log in again. Just let the domain name count for you.

If your environment does NOT have a domain "shell" around it, then it gets trickier. In that case, you need to have a form that comes up no matter what, and that form is your "gatekeeper." You have to secure your system just enough that the switchboard or director form will not allow a person to go on until they have supplied a username and whatever other credentials you need to consummate a login. The form that you don't care if anyone sees is also the form that you can trust be in the Forms collection for just about any version of Access.

If your database allows users to see the navigation pane and the ribbon, then you have no security anyway, so your question would in that case be moot.
 

Users who are viewing this thread

Back
Top Bottom