Login Form Help Needed

G

Guest

Hello,

I would like to have a form displayed (prior to the swtichboard appearing)
that requires the user to enter his/her login information and then click
enter. If the information is correct, the switchboard screen will appear and
the login form will disappear. If not, then a message box appears and the
user has to try again or they won't receive access to the other forms.

I have created a table called Login. This table contains the username and
password. Next I designed a form that will allow the user to type his/her
username and password and then click on the login button.

My code is below however I do not know what I'm doing wrong. Number 1, I'm
not sure how to determine the correct name for the forms when writing the
code (i.e. frame.framename or form.formname, etc).

Private Sub Command10_Click() ->the enter button
'check for correct user name
If Text7 = "nixcynt" Then
'check for correct password
If Text3 = "lookout" Then
'place code to here to pass the
'success to the calling sub
'setting a global var is the easiest
LoginSucceeded = True
'Me.Hide
'frmMenu.fraMain.Visible = True
'frmMenu.fraLogin.Visible = False
DoCmd.OpenForm "Switchboard", acNormal, "", "", , acNormal

Text3_Exit_Exit:
Exit Sub

Text3_Exit_Err:
MsgBox Error$
Resume Text3_Exit_Exit

Else
MsgBox "Invalid UserName/Password. Please try again!", , "Login"
Text3.SetFocus
SendKeys "{Home}+{End}"
End If

Else
MsgBox "Invalid UserName/Password. Please Try Again!"
End If
End Sub
 
K

Keith W

HL said:
Hello,

I would like to have a form displayed (prior to the swtichboard appearing)
that requires the user to enter his/her login information and then click
enter. If the information is correct, the switchboard screen will appear
and
the login form will disappear. If not, then a message box appears and the
user has to try again or they won't receive access to the other forms.

The Built-in Access user-level security will do all this for you and will be
more hack-resistant to a roll-your-own solution. My web site has more
information if you're interested.

Regards,
Keith.
 
G

Guest

Keith,

Could you provide me with more information about this feature. I just need
a step-by-step method of applying user-level security without messing up that
dabase. I really have no experience with this feature. Thanks for your time
and help. By the way, what is the URL of your website?
 
G

Guest

HL

I do this all the time as follows - it is not as secure as Access security,
but I find it is good enough for most applications

1. Change your startup options to display your logon form at starttime
rather than the switchboard, make sure that other "development" options are
switched off (such as show database window) and supply your solution as an MDE
2. When your form is invoked you can do your checks for userid / password
and if not successful, keep the user there until they exit or logon correctly
3. Once they have entered correct information, you can either close the
form, or hide it if you are using it to store information, and then open up
your switchboard.

When the form is displayed and the user has entered their logon informtion
(userid and password), you can DLOOKUP the password in the Login table
against the supplied userid to get the password field. If no row is found,
then error - userid not recognised (msgbox etc and exit sub) , else check the
password supplied against the one returned (if no match error etc)

You should have at least two fields on your form (1) for username (2) for
password
You refer to them as me.fieldname to get the contents (you might want others
to allow the user to change their password occasionally)

So your code in Sub Command10_Click() would look something like:

CorrectPass = Dlookup("password","Login","userid = " & me.text7)

if isnull (CorrectPass) then ' dlookup does not find the userid in text7
msgbox "User not recognised - please try again",vbexclamation,"Login Error"
exit sub
else ' userid found - check password
if me.text3 <> CorrectPass then
msgbox "Incorrect Password supplied - please try again",vbexclamation,"Login
Error"
exit sub
endif
' userid correct and password correct
me.hide
docmd.openform "Switchboard"
 
G

Guest

You don't need a login form, build a table of valid userids (Windows logon
id). You can detect the logon id in code and then scan the table. If it isn't
there, reject the user. No login process is needed. You can even have
different levels of user in the table and show different menus depending on
the level.
The built-in user level security in Access is a minefield of complications
and pitfalls. I would not attempt to use it unless you know what you are
doing.

Dorian
 
K

Keith W

HL said:
Keith,

Could you provide me with more information about this feature. I just
need
a step-by-step method of applying user-level security without messing up
that
dabase. I really have no experience with this feature. Thanks for your
time
and help. By the way, what is the URL of your website?
Sorry, meant to provide that first time www.keith.wilby.com

The FAQ is "all killer, no filler" and you must follow all of the steps in
the order stated, omitting nothing. It's very easy to lock yourself out of
your own file so experiment on dummies first and back up your real file
before attempting to apply security.

Regards,
Keith.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

login form help required 6
error 2489 1
2 users - 1 login - 2 forms 1
Login form 2
Open Form Code 1
Keycode capture on Login form 3
Login form user name and password 6
Lock out a user from using a field 2

Top