Signature for user id

J

JudyT

I need some help with a user id

What I want to happen is...When a user opens the database, I want their
userid to correspond to thier name and then do an electronic signature. Do
you know of any code like that? Please help.
 
C

CW

I'm not an expert and somebody may have a more elegant solution but this is
what I have done:

Firstly of course, the user's id needs to be held somewhere. Perhaps you
have a login page, or an introductory menu page, or if not you could add a
small form to contain this.

Also of course, the signatures need to be held somewhere, probably in jpg
format.

In Design View on the form where the signature is to appear, do "Insert
Image" and bring in the first signature image (placing it and sizing it as
you wish). On the Format tab of Properties for the image, set Visible to No.
Make a note of the name of it (such as Image 21 or whatever is shown).
Repeat this for all the signatures you may need to be shown, laying them one
over the top of the other in the same place on the form.

In the On Current event for the form, use the following code, suitably
adapted for your control/image names and using the pathname to wherever you
are holding the userid:

If <userid> = "johndoe" Then Me.Image25.Visible = True
Else
Me.Image25.Visible = False
End If

(Repeat this for as many signatures as you have)

When the form is open the relevant signature for the logged in user will be
displayed.
 
J

JudyT

CW, I am not sure this is exactly what i need. Here's the rub. There will
be many people signing in on this form. Does every person need to have a
signature on their computer somewhere. Where do i get the signature from.
Very new at this process. please be patient. Thank you for your help.
 
K

ken

I'm assuming, As CW did, that you are talking about placing a
facsimile of the user's signature on a form or report rather than
digitally signing a document for security purposes, which is a far
more complex matter of course.

I've never tried this but it should be pretty straightforward. I
think CW is suggesting embedding everybody's signature as separate
images in the form or report, and hiding all but the current user's.
So the images are stored in the form or report definition, and don't
need to be anywhere else. Another approach, which requires just the
one image control on the form or report would be:

1. Create separate image files of every user's signature.

2. In the database's back end file create a table, UserSignatures
say, with two text columns UserName and ImagePath. Each row in this
table will contain a user's Windows user name, i.e. the name with
which they log in to the system, and the full path to the image file
of their signature, which, like the database's back end file, will be
in a shared folder on the server.

3. Add the following module to the database which enables you to call
the Windows API to get the current user's user name:

''''module basGetUser''''
''''module starts''''
Option Compare Database
Option Explicit

Declare Function GetUserName Lib "advapi32.dll" Alias
"GetUserNameA" (ByVal _
lpBuffer As String, nSize As Long) As Long


Public Function GetUser() As String

Dim strBuffer As String
Dim lngSize As Long, lngRetVal As Long

lngSize = 199
strBuffer = String$(200, 0)

lngRetVal = GetUserName(strBuffer, lngSize)

GetUser = Left$(strBuffer, lngSize - 1)

End Function
''''module ends''''

4. Add an image control to your form or report where you want to show
the signature.

5. In the form's or report's module's Open event procedure set the
picture property of the image control with:

Dim varPath as Variant
Dim strCriteria as String

strCriteria = "UserName = """ & GetUser() & """"
varPath = DLookup("ImagePath", "UserSignatures", strCriteria)

If Not IsNull(varPath) Then
Me.YourImageControl.Picture = varPath
Else
Me.YourImageControl.Visible = False
End If

Ken Sheridan
Stafford, England
 
J

JudyT

First off I there is no back end it is just a database that everyone uses.
Second, how do I embedd a signature. I have their names on a form so far.
Please help guide me.

Thank you,
JudyT
 
J

John W. Vinson

First off I there is no back end it is just a database that everyone uses.
Second, how do I embedd a signature. I have their names on a form so far.
Please help guide me.

I think folks are asking for a clarification of your question, Judy. Do you
want a printable graphical image of a handwritten signature? Or do you want an
"electronic signature", an encrypted binary code which uniquely identifies a
person?

I'm guessing the former; if so, are you planning to ask each person to sign
their name on a sheet of paper and scan those images into .jpg files or the
like?
 
K

ken

Judy:

When you say "it is just a database that everyone uses" do you mean
all users are accessing the same single database file over a network,
or each user is using the same file independently on one machine?

Whichever is the case there are advantages in splitting it into front
and back ends, and as the built in database splitter wizard does all
the work for you, it’s a simple task. With shared access over a
network splitting it is almost de rigueur, and certainly should be
done. The back end can then be placed in a shared folder and separate
copies of the front end installed on each local machine, along with
Access itself.

Whether its split or not is not really directly relevant to your
current problem, however. What's more relevant is that each user logs
in under a user name.

If you want to embed an image scanned each users signature in a form
then its simply a case of adding an Image control to a form or report
and setting its Picture property to the image file, and setting the
control's PictureType property to Embedded. This is the basis of the
method CW describes as you can then hide/show the image relevant to
the current user with code along the lines of that CW gave you. The
problem with this approach, however, is that should a new user be
added you'd need to change the design of the form or report where the
image is shown.

If you use the method I described then all you need to do if a new
user is added is to create the image file of their signature and
insert a new row into the UserSignatures table. Similarly to delete a
user you'd delete a row from the table. In this case the images are
stored entirely outside the database, not embedded in the form or
report objects, but you again use an Image control in the form or
report, but in this case just one and you leave its picture property
blank.

Whichever approach you adopt, you need a means of identifying the
current user of course, so their signature will be used. In a multi-
user environment on a network you can use their system login name,
getting this by means of the GetUser function which I gave you. If
it’s a standalone database which everyone shares without having to log
in then you'd need some way for the user to simulate logging in. This
is easily doe with a dialogue form containing a combo box with a
RowSource of:

SELECT UserName FROM UserSignatures ORDER BY UserName ;

In its AfterUpdate event procedure you can then assign the selected
name to a variable declared Public in any standard module's
Declarations area with:

Public strCurrentUser as String

NB: the above must be in a standard module (the ones listed in the
modules tab of the database window) not a form or report's class
module.

The code for the combo box's AfterUpdate event procedure would be:

Dim ctrl As Control

Set ctrl = Me.ActiveControl

strCurrentUser = Nz(ctrl,"")

If you use my method with the images in external files you'd no longer
need to cal the GetUser function, so the code to assign the image to
an Image control in a form or report would have the following amended:

strCriteria = "UserName = """ & strCurrentUser & """"

Using CW's method, embedding all images in the form or report, you'd
amend the following line:

If strCurrentUser = "johndoe" Then Me.Image25.Visible = True

With CW's method the UserSiganatures table doesn't need the ImagePath
column of course as the images are embedded, so don't need to be
loaded from the external files.

Ken Sheridan
Stafford, England
 
J

JudyT

Ken,
It is a stand alone database that will be on the network where everyone will
access it. It is just to get thier signatures based on their userid. I
don't understand where to start with this function...can you give me step by
step instructions. I am very very new at this. I don't know code or how to
use it.

Please help.
 
K

ken

Judy:

I think I've already done that in my original reply. The only
difference is that your database is a single file, but as its on a
network everyone will have to log in, so will have a user name you can
use to identify them. Here's what I said, modified very slightly to
take account of the one-file set up:

1. Create separate image files of every user's signature.

2. In the database create a table, UserSignatures
say, with two text columns UserName and ImagePath. Each row in this
table will contain a user's Windows user name, i.e. the name with
which they log in to the system, and the full path to the image file
of their signature, which will be in a shared folder on the network.

3. Add the following module to the database which enables you to call
the Windows API to get the current user's user name:

''''module basGetUser''''
''''module starts''''
Option Compare Database
Option Explicit

Declare Function GetUserName Lib "advapi32.dll" Alias
"GetUserNameA" (ByVal _
lpBuffer As String, nSize As Long) As Long

Public Function GetUser() As String

Dim strBuffer As String
Dim lngSize As Long, lngRetVal As Long

lngSize = 199
strBuffer = String$(200, 0)

lngRetVal = GetUserName(strBuffer, lngSize)

GetUser = Left$(strBuffer, lngSize - 1)

End Function
''''module ends''''

4. Add an image control to your form or report where you want to show
the signature.

5. In the form's or report's module's Open event procedure set the
picture property of the image control with:

Dim varPath as Variant
Dim strCriteria as String

strCriteria = "UserName = """ & GetUser() & """"
varPath = DLookup("ImagePath", "UserSignatures", strCriteria)

If Not IsNull(varPath) Then
Me.YourImageControl.Picture = varPath
Else
Me.YourImageControl.Visible = False
End If

I can't really see what I can add to that to make it any clearer, but
if you're really stuck, then mail me at:

kenwsheridan<at>yahoo<dot>co<dot>uk

and I'll put together a simple little file for you to demonstrate how
it can be done.

BTW I really would recommend splitting your database. It only takes a
few moments with the wizard. You can then put a copy of the front end
on each user's machine, which is not only more efficient, but a lot
safer, as if one copy of the front end becomes corrupted the data in
the back end is untouched, and you simply have to replace the front
end with a new copy from a 'master' copy kept somewhere safe. It also
means you can back up the data regularly without backing up all the
unchanging objects like forms, reports etc. You do back up regularly,
don't you!!!

Ken Sheridan
Stafford, England
 
C

chris

Ken,

I'm trying to do something similar and can not follow the code you
outlined below. I have a table with a username and path field for the
scanned copy of that users signature. What I want to happen is on a
form I have a pull down list with all the users names. When the user
selects their name, I want their signature to appear in an Image
field. How can I use your concept below to work for that? I was
thinking of adding code in the AfterUpdate event on the pull down
list, but I'm not sure how to write the code to look at the username
in the combo box and make the image field equal some file out on the
network. I do not want to have a bunch of hidden image fields on the
form. I have done this in the past and agree its not good when new
users are created.

Any help you could provide would be great.

Regards,

Chris
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top