Help with creating a logon form in access

T

Tellis2112

I'm putting together a dbase that has a logon page. I have a table with
users' information (logon, password, etc.). I've created a form for users to
log in from and added some code to validate it against the users' table to
make sure that the password and logon matches.

Here's where I'm stuck. Once the user has logged in, I need to filter all
the records they view to only their own records. Any data that they
contribute needs to be stamped so that I can see who entered it. So I need
to store the user's name/id somewhere in the open file so that I can filter
the forms and reports by the 'current user'.

Can anyone tell me the best way to store "temporary information" that can be
used to filter reports, queries and forms?
 
R

Ryan

I have done the same thing as you and built my own custom security. The way
I filter and namestamp is to have a form that always stays open, which in my
case acts as a switchboard. I base that form on the users table so I can
pull out the PK, wich can be a UserID or Username, on to the form. From that
point I include the users table in all my queries and add this Criteria,
=[Forms]![UsersSwitchboard]![LoggedInUsername]. If you are on a form and
need to grab the UserName it would look something like [UserName] =
[Forms]![UsersSwitchboard]![LoggedInUserName].
 
N

Noob

Im a noob, but maybe something like this will work.

Create a module and put in something like

Public strUserName As String

In the top of the module

Say your field that the user fills in his/her name is called txtUserName.
Then you may have a button to perform the login.
In the buttons click-event, you put the following.
(This comes after your validation of password.)

strUserName = txtUserName

Then the username will be stored in strUserName, and can be used everywhere
in the application.

/Noob
 

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