Hi Deb
Sorry if my answer in your
other thread was a little vague. I have found my old database with the (elementary) password control and following are instructions on how to set it up to test the password and then base the main form on the user id. There is no short way of describing this so here goes :
tblUsers
Logon_ID (unique, key)
Name
Password (text with an input mask of "password" - without the quotes, Required = Yes)
You could add other fields but the above list is the minimum I would expect
frmLogon
Basic form with 4 elements, not based on any table or query whatsoever :
Unbound text box with the name "ID_Attempt" (without the quotes)
Unbound text box with the name "PW_Attempt" & an input mask of "password" (both without the quotes)
OK button, which runs mcrLogon.Start in the "Onclick" event (ask if you are unsure)
Quit / Cancel button, with the VB command "DoCmd.Quit" attached to the onclick event (again, ask if you are unsure)
On the main database screen, click on Tools -> Startup -> under "Display Form/Page" select "frmLogon".
qryCheckPW
Paste this SQL into the query SQL design screen:
SELECT tblUsers.Logon_ID, tblUsers.Name, tblUsers.Password
FROM tblUsers
WHERE (((tblUsers.Logon_ID)=[Forms].[frmLogon].[id_attempt]));
qryCheckID
SELECT Count(qryCheckPW.Logon_ID) AS CountOfLogon_ID
FROM qryCheckPW;
frmCheckID
based on qryCheckID, add the "CountOfLogon_ID" field. Don't worry about formatting this form, it is not for viewing.
frmCheckPW
based on qryCheckPW, add the 3 fields. Don't worry about formatting this form, it is not for viewing except make sure the password field has an input mask of "Password" (without the quotes).
mcrLogon
After you create the macro, but before you enter any of the lines below, click on View -> Macro Names and also click on View -> Conditions. I have used the following formats for the lines on the macro : Line number (not actually entered into the macro but I have included it so you can follow this) : Macro name (if nothing, leave blank) : Condition : (if nothing, leave blank) : Action : Action Arguments (if any)
1 : Start : : OpenForm : frmCheckID, Data Mode = Read Only, Window mode = hidden {NB: per my format instructions above, there is no condition for this line hence the double ":"}
2 : : [Forms]![frmCheckID]![CountOfLogon_ID]<>1 : RunMacro : mcrLogon.WrongID
3 : : ... : StopMacro
4 : : : Close : Form, frmCheckID, No
5 : : : OpenForm : frmCheckPW, Data Mode = Read Only, Window mode = hidden
6 : : IsNull([Forms]![frmLogon]![PW_Attempt]) Or ([Forms]![frmLogon]![PW_Attempt]<>[Forms]![frmCheckPW]![Password]) : RunMacro : mcrLogon.WrongPW
7 : : ... : StopMacro
8 : : : Close : Form, frmCheckPW, No
9 : : : OpenForm : (Enter the name of your vacation request form), Set the view you want, Filter = blank, Where = "[Your user id field name on your form]=[Forms]![frmLogon]![ID_Attempt]", Data Mode = blank or restrict it to add or edit, Window mode = normal
10 : : ... : StopMacro
11 : : :
12 : WrongID : : MsgBox : enter a warning message for the user and change the type to "Warning!"
13 : : : Close : Form, frmCheckID, No
14 : : ... : StopMacro
15 : : :
16 : WrongPW : : MsgBox : enter a warning message for the user and change the type to "Warning!"
17 : : : Close : Form, frmCheckPW, No
18 : : ... : StopMacro
This could probably be tremendously simplified using VB but I don't know enough about VB to convert this entire process (yet).
Be aware that basic security such as this can be circumvented by holding down the shift key when the database starts, or by importing or linking the user table into another database - but those are separate issues.
If you are not sure of something please ask.
HTH, Andrew.