Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

My own security hang-up . . .

Status
Not open for further replies.

Brambojr

Technical User
Oct 26, 2000
73
US
Help!

For a long list of reasons I have elected to create my own "security" to a new db I am putting together. I have hit one snag.

I have built a form for users to enter userId and Password and have all the desired actions all perfect, EXCEPT . . . What is the best way of making sure that these two values are valid? I obviously need the thing to exclude some and allow others, how can I code this??

I am at an impasse. Help me please?

Am new to VBA, but learning somewhat quickly.

Thanks in advance for any help,

Brambojr
 
Why try and invent the wheel all over again? Let Access do the work for you. Since you're only trying to invoke a password system Access will lead you by the hand. Even the user level security is not as formidable as it was in Ver. 1 and 2 because of the new wizards.

Just look in Help under Security and select the password option. That should get you what you want painlessly.

Uncle Jack
 
Brambojr,

If you really do want to use your own security, then you'll need to know some DAO or ADO to do so.

Set up a table called tblPassword. Create the fields, LoginID and Passwords. Set LoginID to be the primary key.

In your form, on the click event of the login button, put the following code. I've assumed that you've called the text box for the login name txtLogin, the textbox for the password txtPassword, the command button cmdLogin and the form you wish to open to be frmFirstForm.

If you need any more help, shout!

HTH

Craig

Private Sub cmdLogin_Click

Dim db as Database
Dim rst as Recordset

If len(txtLogin)>0 Then
Set db=CurrentDB
Set rst=db.OpenRecordset("SELECT * FROM tblPassword WHERE LoginID = '" & txtLogin & "'"
With rst
.MoveLast
.MoveFirst
If rst.RecordCount > 0 THEN
If rst!Password = txtPassword THEN
DoCmd.OpenForm "frmFirstForm"
Else
MsgBox "Password does not match. Login denied"
End If
Else
MsgBox "Please enter a valid login"
End If
End With
rst.Close
Set rst=Nothing
set db=Nothing
Else
MsgBox "Please enter a valid login"
End If

End Sub
 
Thanks for the help there. I am trying to get it to work now, but am getting "User defined type not defined" messages for the dim db as database line. I can't seem to get the puter to go past that line in any code. . . .what would be causing it?

Any ideas?

Thanks for the help Brambojr
 
Nut what's the Use?
You can just hold down shift when starting the Database and it will bypass the Password?
Eldaria

That was my 25cent** of opinion.

** Inclusive Intrest, tax on interest, Genral tax, Enviromental tax, Tax, and tax on intrest, tax on fees, tax on tax, and other Various taxes and fees.
 
BramboJr,

I wrote the code in Access97 using DAO. I suspect you are using Access2000. If so, you'll need to convert the code to ADO or go to Tools, References and add the reference for DAO. You'll then need to prefix my declared variables with DAO.

i.e. Dim DB as DAO.Database

Craig
 
Just what the doctor ordered. Thanks for the help. Now the biggest hitch to this thing is tackled. Thanks.

Brambojr
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top