set password in a form's control

  • Thread starter Thread starter Jason
  • Start date Start date
J

Jason

Hi,

I was wondering how i could save a password in a form's control.

I've created a configuration form where one can set database specific
values, like databasename, portnr, etc. But they also need to set up a
password and i don't want it to store in a table.

So i did the following. In a textbox's afterupdate-event i set the
controlsource's value to the value i just typed in. So far so good.

However when i close en reopen the form, nothing's there.

Is this the right way to do this or should i approach i differently
 
Hello Jason,

You should use a declare a Public Variable in a module and set that in the
AfterUpdate event of the control. In code you can then refer to the variable
when needed. I usually set up a Module called Global Declarations and
place all my Public Variables there, like:

Public pubPW As String
Public pubUser as String



God Bless,

Mark A. Sam
 
Keep in mind. Users can still get to the data by opeing your table
directly. A savvy user can also simply read your code and see the password.
Also, why make your senior employees type passwords everytime they want to
get to a secure form?

Personally, I would never use a password in code. Use Access's built-in
User-Level Security and only allow the authorized users to get to the form.
Every user then signs on once and only once when they open the application.
They can then do only the activities you have defined.
 
Jason,

An example would be to create a module and name it something like
GlobalVariables.

Open the module and it will look like this:

Option Compare Database
Option Explicit

Skip a line after Option Explicit and type:

Public pubPassword As Variant

Of any other name for the variable that you choose.

Save the Module.

Open the AfterUpdate Event Procedure of the form's textbox there you will
type in the Password. Type in the following line:

pubPassword = Me.ActiveControl

Close the event procedure and save the form. You may also want to complile
before you close the Event Procedure to check for syntax or other errors.

Now when the Textbox is updated, the variable will be updated.

Note that when I declared the Variable I used a Variant datatype. This is
to avoid problems with Null values that may occur with String variables.

God Bless,

Mark
 
Back
Top