Here you go:
SELECT vehiclelistingtbl.[VIN #], vehiclelistingtbl.[Inventory #],
vehiclelistingtbl.[Tag #], vehiclelistingtbl.[Vehicle Type],
vehiclelistingtbl.[Vehicle Year], vehiclelistingtbl.Passenger,
vehiclelistingtbl.[Marked Vehicle], vehiclelistingtbl.Active,
vehiclelistingtbl.Division, vehiclelistingtbl.Location,
vehiclelistingtbl.assignedperson, vehiclelistingtbl.vehiclenotes,
usernameregion.region, usernameregion.username
FROM vehiclelistingtbl INNER JOIN usernameregion ON
vehiclelistingtbl.Location = usernameregion.region
WHERE (((vehiclelistingtbl.Active)=True) AND
((usernameregion.username)=CurrentUser()));
--
Todd
:
Open the vehicleregionqry query in design view and then choose View,
SQL;
copy and paste that statement in a reply here.
--
Joan Wild
Microsoft Access MVP
This is what I copied from the secfaq Item 22 into a module I named
usergroupidentifymodule:
Function faq_IsUserInGroup (strGroup As String, strUser as String)
As
Integer
' Returns True if user is in group, False otherwise
' This only works if you're a member of the Admins group.
Dim ws As WorkSpace
Dim grp As Group
Dim strUserName as string
Set ws = DBEngine.Workspaces(0)
Set grp = ws.Groups(strGroup)
On Error Resume Next
strUserName = ws.groups(strGroup).users(strUser).Name
faq_IsUserInGroup = (Err = 0)
End Function
And this is what I entered in the Vehicle Form Event "On Open"
Private Sub Form_Open(Cancel As Integer)
If faq_IsUserInGroup("Admins", CurrentUser) Then
Me.RecordSource = "SELECT * FROM vehicleregionqry"
Else
Me.RecordSource = vehicleregionqry
End If
End Sub
It wouldn't let me enter the <> at the beginning and end of
Me.RecordSource
= <vehicleregionqry>. Should this be in it? The vehicleregionqry is
my
recordsource for the vehicle form so that's why it is in the above
code
twice. Should there be a different query there?
In my menu screen where the users select their region I've got 5
switchboard
options for Region 1-5 and each of them have different queries but
with
the
same fields and all come from the same vehiclelistingtable. I
entered
the
info you told me previously (user/group table) and added these field
to
each
query and entered Currentuser() in the user criteria of each query.
This
did
work fine but as an admin user when I logged in and selected a
region
to
open
I couldn't open any of them since I wasn't assigned to one of the
regions.
--
Todd
:
That function is available in the security FAQ. You can download
it
from
http://support.microsoft.com/?id=207793
Put it in a standard module (give the module a different name than
the
function)
--
Joan Wild
Microsoft Access MVP
When I entered the code you suggested below, it gave me an error
of
"Sub
or
Function not defined". What should I put in the part of the code
faq_IsUserInGroup? The name of my table where it identifies the
users
and
region they belong to is usernameregion and the two fields in the
table
are
user and region.
--
Todd
:
You can use the open event for your form to set the
recordsource...
If faq_IsUserInGroup("Admins",CurrentUser) then
Me.RecordSource = "SELECT * FROM YourQuery"
Else
Me.RecordSource = <the existing recordsource you have>
End If
If this doesn't work, post the recordsource that you currently
are
using.
You do not need the combo since the recordsource is restricted
to
'their'
region.
--
Joan Wild
Microsoft Access MVP
What should I do for myself and another user that I've given
admin
rights.
We are really not assigned a region so by making the changes
you
suggested
we
can't open any of the regions via the front end (or exe). I'd
like
for
us
to
be able to open any of the regions through the exe?
The things you suggested to me work good. When the users try
and
select
another region should it just go to a blank screen because it
does.
They
would just then need to click the close box and it would go
back
to
the
previous menu screen.
--
Todd
:
I suggest you have a separate table with the Access username
and
the
Region
they belong to.
Then in your queries and form recordsources you can add this
table
and
link
on the Region; put a criteria under the username of
CurrentUser().
--
Joan Wild
Microsoft Access MVP
Joan,
Piggybacking on the previous question and your response, if
one
of
my
groups
is the "Full Data User" group and I've got users assigned
to
that
group,
how
can I restrict them from accessing certain forms once they
are
logged
in.
EX: Each of my users are from a different region and I'd
only
like
for
them
to access their regions information to enter/edit/delete
data.
In
my
dbase
I've got command buttons (with a macro tied to each of them
to
sort
and
open
only each specific regions data) where all users can select
their
region.
The problem is that they have the ability to select any of
the
regions
if
they like.
Would I do this under the "users and group permissions"
dialog
option?
I
did this for my region1 user as a test and selected only
the
macro
that
I
wanted to allow region1 to have access too but it still let
them
in
the
other
regions even though I didn't select the other regions
openmacro.
Help!
--
Todd
:
The dialog box only shows explicit permissions, not
implicit
(i.e.
those
inherited from group membership).
It is possible to assign permissions to users, however
that
isn't
recommended as it's difficult to maintain.
--
Joan Wild
Microsoft Access MVP
"fennellkevin" <
[email protected]>
wrote
in
message
When Users are assigned to specific User groups (ex: New
Data
Users),
when
the User and Group Permissions dialog box is viewed,
only
the
permissions
of
the Groups are shown and not the individual users (ie:
when
the
"Users"
bullet is checked)
Why is this?