Hi, Lea.
How do I determine who the current user is?
The built-in Access function CurrentUser returns the UserID that was used to
log into the database. When the default workgroup is used, this is Admin.
When a secured workgroup is used, it will be the name typed into the "Name:"
text box in the Logon dialog window.
As mentioned in another post, I do not have the ability to create seperate
computer logins
So everybody is using the same computer and computer login ID, but your
application needs to be able to differentiate who is operating the computer
when each record is manipulated. A login with a password will accomplish
this.
If your goal is to become a proficient VBA programmer, then start by
creating a new text box on your form and name it txtUserName so that the
code George gave you will compile. Continue writing and debugging the rest
of the code needed to implement home grown security.
If you are using Access 2002 or 2003, and your goal is to make the
application as simple to write and maintain as possible, then:
1.) Add the LastUpdatedBy field to your table and the query used as the
recordset for your form; and
2.) Create a bound text box to this field on your form and name it
txtLastUpdatedBy; and
3.) Implement user-level security with the Security Wizard; and
4.) Place the following code in the module of each form that needs a name
stamp from whomever logged into your database application:
' * * * * * Code Start * * * * *
Private Sub Form_AfterUpdate()
On Error GoTo ErrHandler
Me!txtLastUpdatedBy = CurrentUser
Exit Sub
ErrHandler:
MsgBox "Error in Form_AfterUpdate( ) in" & vbCrLf & Me.Name & _
" form." & vbCrLf & vbCrLf & _
"Error #" & Err.Number & vbCrLf & Err.Description
Err.Clear
End Sub
' * * * * * Code End * * * * *
Whenever a new user needs to use the database application, all he needs to
do is double-click on the shortcut icon (created by the Security Wizard or
by you) on the desktop, type his name and password in the Logon dialog
window, then operate the application. Each updated record or new record
will have the UserID of the person who logged into the application placed in
the LastUpdatedBy field of the table. When the next user needs to use the
application, he closes Access, then the next user double-clicks on the
shortcut icon on the desktop, types his name and password in the Logon
dialog window, then operates the application, too.
my Access Security Management attempts have been less
than stellar
Excellent! This means you've had practice with user-level security and you
already know plenty of things _not_ to do. You also know how frustrating it
can be when things go wrong, so you practice on a copy of your database,
instead of the original. Most people who use Access are complete novices
when it comes to user-level security, so you are way ahead of them.
User-level security is not simple, but the important things to remember are:
1.) Follow all of the steps, in order. Don't skip any.
2.) Make sure that the user is joined to the default workgroup, but uses a
shortcut to open the secure database, which temporarily joins the user to
the secure workgroup while the database is open. This way the user will
only be prompted for UserID and password for the secured databases, not the
unsecure ones.
3.) Practice on a copy first, then implement security on the production
version.
For #1, the best set of instructions I've seen is Joan Wild's (Access MVP)
step-by-step instructions on this Web page:
http://www.JMWild.com/AccessSecurity.htm
(You still need to read the SecFAQ on this Web page for background
information and troubleshooting
http://support.microsoft.com/default.aspx?scid=/support/access/content/secfaq.asp
For #2, please see the tip "How to open databases and only be prompted for
User ID and password for the secure databases" for instructions on how to
create the shortcut on the following Web page:
http://www.Access.QBuilt.com/html/security.html
HTH.
Gunny
See
http://www.QBuilt.com for all your database needs.
See
http://www.Access.QBuilt.com for Microsoft Access tips.
(Please remove ZERO_SPAM from my reply E-mail address, so that a message
will be forwarded to me.)