Chip,
I would not create a button for each user. I would create
a user table with password for each user. The easiest way
is to have a hidden form that opens upon startup. On the
hidden form place a text field. When the application
opens, the hidden form will open and a signon screen. On
the signon scvreen you would have a combobox that has the
userID from your user table as its control source. On the
signon screen put a hidden text box. For the sake of this
post call it sysPassword. Have another visible text field
called userPassword. In the Afterupdate event for the
userID field put vba code which would look something like
this:
dim db as database 'database object
dim rst as recordset 'record set object
dim sqlStr1 as string 'sql string
dim SelUserID ' selected user id
set db=currentDB
selUserID=Me!userID
sqlStr1 = "Select password from users where userID='" &
selUserID & "';"
'********************************************************
Note: the easiest way to write your sql string is to
create the query in the query building, then switch to SQL
view mode and copy the SQL code from there. Past it into
the VBA window.In VBA the userID value coming from the
form must be surrounded as follows '" & selUserID & "'.
When you create the query in the query builder, test it.
Make sure your user form is open in normal view and has a
user selected. If it brings back one user with the correct
information, your good to go.
'*********************************************************
'code continued
set rst=db.openrecordset(sqlStr1,dbopensnapshot)
Me!sysPassword=rst!password
db.close
set db=Nothing 'release memory for db and rst objects
set rst=Nothing
end sub
Place a button on the form using the wizard. In the
wizard, select open form and pick the next form you want
to open. After the wizard places the button on the form,
select the button (this is in design view still) and go to
the poperties page for the button. find the onClick event
and click on the elipses (...). This will open the VBA
window for the onclick event for this button. There should
already be code there to open the form you selected. The
wizard should have put a command that looks something like
the following:
DoCmd.OpenForm "YourForm"
Place before that command the following command:
if(Me!sysPassword=Me!selPassword) Then 'compare hidden
password field with what the user entered.
DoCmd.OpenForm "YourForm"
etc.etc.
endif
When you open the form (Docmd.Openform) you can use either
a filter which is a query created with the query builder
or you can use a Where condition. Either way, you should
be able to accomplish your task. I have personnaly had
more problems with the Where condition, but there is
probably something I am doing wrong consistently. I can
test the query and know it works.
Hope that helps! I know it's a lot to throw at you. If you
need more help, feel free to post back.
Kevin