Filter views based on login/PID

L

Lori

I am trying to filter/restrict access of records based on
how a user is logged in - not who created the records.
For example, I want a salesperson to be able to only view
their orders. They have a login and I have created user
names/groups. Someone answered a similar question below,
but I don't want to base views by who created the records,
but by who "owns" it (their employee name is in an
employee table and is linked to each form/report).

Thanks,

Lori

An easier & simpler method is to do it
through VBA code. Define a field in each table, to hold
the username of the
user who created that record. Code the BeforeUpdate event
of each form, to
put the value of the CurrentUser() function into that
field. Now each record
knows who created that record. Then base each form on a
query like:

SELECT * FROM MyTable WHERE CreatedBy = CurrentUser()
 
T

TC

Given a record, how should the system answer the question, "Which users are
allowed to see this record?".

TC
 
L

Lori

Sometimes another person will create the record for the
salesperson. so the answer is yes.
 
L

Lori

The "employee" that is attached to each record. I need to
find a way to tie in the login/PID to the employee, so I
could filter the records by whoever is logged in.
 
T

TC

Sorry, I still don't understand.

- How is an employee "attached" to each record?

- What do you mean, to "tie the login/PID to the employee"?

Perhaps give us a specific example.

TC
 
G

Guest

For example: I have a table called Employees and a table
called Sales Orders. When entering a Sales order, the
data entry person selects an employee from a combo box
(which is linked to the employee table). When a
saleperson logs in I want them to only see the Sales
Orders that have their employee name selected. They do
not enter their own orders, so I can't do the CurrentUser
() owns record. I can add the login information to the
employee table if I need to.
 
T

TC

Ok - *now* I've got you!

So, Dick Jones enters a new sales order, and during the data entry process,
he assigns that order to salesperson Jane Smith.

Then, whenever salesperson Jane Smith logs on, she should be able to see
that order. Other salespersons should *not* be able to see that order.

Here's how I'd do it.

Take the combo box where the data entry person says which salesperson the
new order is for. Have that combo box display the salesperson's name (eg.
Jane Smith), but actually *save into the record* the salesperson's *Access
username* (JSmith or whateever).

Then just base the salesperson's form on a simple query:

SELECT * FROM SalesOrders WHERE ForUser = CurrentUser()

where ForUser is the field containing the Access username of the salesperson
who that order is for.

Simple! Yes? No?

HTH,
TC
 
L

Lori

Thanks! I think this is just what I need. Now all I have
to do is tackle installing security correctly.
 

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