yeah, i want only people with a password to be able to open a form. i have a switchboard with 4 buttons - each one opens a particular form, and i want only one of those buttons to be password-protected. the administration button. how can I do this?
Ok, Try this
1. You need to popup a Password form, when user clicks Password protected button
2. Your pssword form consists 3 controls one for User name(if you need),another for password and a command button.
3. In Password Form Command Button Click event Check user authentication then allow to see info.
In Command Button Click event
a) Check for PWD In database
2) If password matches then open a new form with info, if not popup a message and close the password form
Hope this helps Please remember to give helpful posts the stars they deserve!
This makes the post more visible to others in need!
1. Add a Form to your database say Password
2. Add 4 Controls 1.txtUserName,2.txtPassword,3.CmdOk and 4.cmdCancel
3.Go to txtPassword textbox Properties.Click on Data Tab and Set InputMask to Password
4.In cmdOk Click event Check Password in Database and
if it is a valid password then show detail form.
DoCmd.OpenForm "Detail Form"
else show a message Incorrect Password message and close the form.
5.in CmdCancel click event close the form
DoCmd.Close A_FORM, "Password"
Please remember to give helpful posts the stars they deserve!
This makes the post more visible to others in need!
1. you need to create a table say Security with minimum 3 fields.
a. UserId Number/Text (Key Field)
b. UseName Text(50)
c. Password Text(50)
If you want you can add any other Info Like Secuty Level etc...
2.In CmdOk Click Event you need to write a SQL Statement like
Dim Curdb As Database, SQLStmt As String, SecTB As Recordset
Set Curdb = CurrentDb() 'If your table and form are in same database other wise change it
SQLStmt = "SELECT * FROM [Security] WHERE [UserName] = '" & Trim("" & Me![txtUserName]) & "'"
SQLStmt = SQLStmt & " [Password] = '" & Trim("" & Me![txtPassword]) & "'"
Set SecTB = Curdb.OpenRecordset(SQLStmt, DB_OPEN_DYNASET)
If SecTB.EOF Then
MsgBox "Logon ID or Password not found!", 16, "Incorrect Logon Information"
SecTB.Close
Exit Sub
End If
SecTB.Close
DoCmd.OpenForm "Detail Form" Please remember to give helpful posts the stars they deserve!
This makes the post more visible to others in need!
Great solution. Though I am having two problems. One is that even after opening the form, password form stays open beneath which should be closed and secondly, since I am calling my form based on a parameter query, when I cancel the parameter I get very unsightly message that the action was canceled. I wonder if you could add additional couple of lines to this code.
1.Please Include DoCmd.Close A_FORM, "Password" Immediatly after DoCmd.OpenForm "Detail Form" .
Then your code in cmdOk Click event Looks like
DoCmd.OpenForm "Detail Form"
DoCmd.Close A_FORM, "Password"
Forms![Detail Form].Setfocus
2. Can you post more details about this ? Please remember to give helpful posts the stars they deserve!
This makes the post more visible to others in need!
emergplan: You must set a reference to Microsoft DAO 3.6. Object library to run that piece of code.
Before doing that, fully qualify the variable:
Dim curdb As DAO.Database
If you don't want to set the reference, you will have to change the code to ADO model (curdb will be a Connection object instead of Database, and SecTB will be an ADODB.Recordset instead of DAO.Recordset):
Dim curdb As ADODB.Connection
Dim SecTB As New ADODB.Recordset
Set curdb = CurrentProject.Connection
...
SecTB.Open SQLStmt, curdb, adOpenDynamic, adLockOptimistic
Good luck
Daniel Vlas
Systems Consultant
danvlas@yahoo.com
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.