How to restrict users to see data in a mutiuser environment?

G

Guest

I have a timekeeper database where one timekeeper from each department will
keep their own employee time. I need to restrict the view of data for each
department so each deprtment can see only their own peoples data. How can I
do that? At this point I am clueless since I am a novice Access User.
I appreciate all the replies.
 
G

Guest

First, the easy part.
Filter the form by department number so only that department's employees
will be included.

Now the hard part. That is, to know which department should be included.
Since I don't know enought about your applicatioin, I don't know if you are
using security or if you have any way of knowing who the user is and what
that user's deparment is. This is the part you will have to determine. The
question is "How do I know which department to filter on?"

If you can define how you will know that, I will be happy to help with the
coding of it.
 
G

Guest

Thanks alot for the response.
For the first part, I am using a combobox on the mainform where the user
will select the dept and it will take them to the data entry form for that
department only.

For the second part, I would like use Access Security where each timekeeper
will have a username and password with the WorkGroupInformationFile.
When database opens up, the user need to put in the userid/password, and
then it will take them to the mainform. In the mainform they will select
their department, and so on. How do I do that? Thanks again
 
G

Guest

You would need to have the combo with all the departments on the form from
which you open the form you want to filter. Then when you open the form
Docmd.OpenForm "MyForm", , ,"[Department] = '" & Me.cboDepartment & "'"
The above is if the Department field in your table is a text field. If it
is numeric:
Docmd.OpenForm "MyForm", , ,"[Department] = " & Me.cboDepartment
 
G

Guest

Thanks.
My combo is a text field and it works fine with the filtering. Thanks fir
the code.
Now how would I set up the security? If a time keeper logs in how would I
restrict them to see their specific dept data?
Thanks in advance for the response.
--
thadi


Klatuu said:
You would need to have the combo with all the departments on the form from
which you open the form you want to filter. Then when you open the form
Docmd.OpenForm "MyForm", , ,"[Department] = '" & Me.cboDepartment & "'"
The above is if the Department field in your table is a text field. If it
is numeric:
Docmd.OpenForm "MyForm", , ,"[Department] = " & Me.cboDepartment

Tasmania said:
Thanks alot for the response.
For the first part, I am using a combobox on the mainform where the user
will select the dept and it will take them to the data entry form for that
department only.

For the second part, I would like use Access Security where each timekeeper
will have a username and password with the WorkGroupInformationFile.
When database opens up, the user need to put in the userid/password, and
then it will take them to the mainform. In the mainform they will select
their department, and so on. How do I do that? Thanks again
 
G

Guest

The code I posted will show only the selected department when the form is
opened.

If you plan to use workgroup security, you could assign users to groups by
department, then set the filter based on the group of the user that is the
current user.

Tasmania said:
Thanks.
My combo is a text field and it works fine with the filtering. Thanks fir
the code.
Now how would I set up the security? If a time keeper logs in how would I
restrict them to see their specific dept data?
Thanks in advance for the response.
--
thadi


Klatuu said:
You would need to have the combo with all the departments on the form from
which you open the form you want to filter. Then when you open the form
Docmd.OpenForm "MyForm", , ,"[Department] = '" & Me.cboDepartment & "'"
The above is if the Department field in your table is a text field. If it
is numeric:
Docmd.OpenForm "MyForm", , ,"[Department] = " & Me.cboDepartment

Tasmania said:
Thanks alot for the response.
For the first part, I am using a combobox on the mainform where the user
will select the dept and it will take them to the data entry form for that
department only.

For the second part, I would like use Access Security where each timekeeper
will have a username and password with the WorkGroupInformationFile.
When database opens up, the user need to put in the userid/password, and
then it will take them to the mainform. In the mainform they will select
their department, and so on. How do I do that? Thanks again


--
thadi


:

First, the easy part.
Filter the form by department number so only that department's employees
will be included.

Now the hard part. That is, to know which department should be included.
Since I don't know enought about your applicatioin, I don't know if you are
using security or if you have any way of knowing who the user is and what
that user's deparment is. This is the part you will have to determine. The
question is "How do I know which department to filter on?"

If you can define how you will know that, I will be happy to help with the
coding of it.

:

I have a timekeeper database where one timekeeper from each department will
keep their own employee time. I need to restrict the view of data for each
department so each deprtment can see only their own peoples data. How can I
do that? At this point I am clueless since I am a novice Access User.
I appreciate all the replies.
 
G

Guest

What is the best practice in this situation? Should I use Workgroup security
or should I use some other approach? What would be any other approach? I
hope I am not asking too much? Since I am a novice Access user, please don't
be annoyed. Thanks.
--
thadi


Klatuu said:
The code I posted will show only the selected department when the form is
opened.

If you plan to use workgroup security, you could assign users to groups by
department, then set the filter based on the group of the user that is the
current user.

Tasmania said:
Thanks.
My combo is a text field and it works fine with the filtering. Thanks fir
the code.
Now how would I set up the security? If a time keeper logs in how would I
restrict them to see their specific dept data?
Thanks in advance for the response.
--
thadi


Klatuu said:
You would need to have the combo with all the departments on the form from
which you open the form you want to filter. Then when you open the form
Docmd.OpenForm "MyForm", , ,"[Department] = '" & Me.cboDepartment & "'"
The above is if the Department field in your table is a text field. If it
is numeric:
Docmd.OpenForm "MyForm", , ,"[Department] = " & Me.cboDepartment

:

Thanks alot for the response.
For the first part, I am using a combobox on the mainform where the user
will select the dept and it will take them to the data entry form for that
department only.

For the second part, I would like use Access Security where each timekeeper
will have a username and password with the WorkGroupInformationFile.
When database opens up, the user need to put in the userid/password, and
then it will take them to the mainform. In the mainform they will select
their department, and so on. How do I do that? Thanks again


--
thadi


:

First, the easy part.
Filter the form by department number so only that department's employees
will be included.

Now the hard part. That is, to know which department should be included.
Since I don't know enought about your applicatioin, I don't know if you are
using security or if you have any way of knowing who the user is and what
that user's deparment is. This is the part you will have to determine. The
question is "How do I know which department to filter on?"

If you can define how you will know that, I will be happy to help with the
coding of it.

:

I have a timekeeper database where one timekeeper from each department will
keep their own employee time. I need to restrict the view of data for each
department so each deprtment can see only their own peoples data. How can I
do that? At this point I am clueless since I am a novice Access User.
I appreciate all the replies.
 
G

Guest

If you are new to Access, setting up workgroup security can be a little
intimidating. It would be the best solution, however.

Another way would be to create a table of users and the deparment codes they
belong to. If only certain users are able to look at the data, then only put
those users and their department codes in the table.

Then you will need to know who the logged on user is. Put this code in a
standard module:

Private Declare Function GetUserNameA Lib "Advapi32" (ByVal strN As String,
ByRef intN As Long) As Long
Public Function GetUserID()
' Gets the userid (5+2) of the current user.
' Put the following in the declarations section:
'Private Declare Function GetUserNameA Lib "Advapi32" (ByVal strN As String,
ByRef intN As Long) As Long
' modified 4/11/02 dbk set default userid for those not on network

'set default to xxx, changed 10 to 20 for length on 2 lines

Dim buffer As String * 20
Dim Length As Long
Dim lngresult As Long, userid As String

Length = 20

lngresult = GetUserNameA(buffer, Length)
If lngresult <> 0 Then
userid = Left(buffer, Length - 1)
Else
userid = "xxxxxxx"
End If
'MsgBox "USERID = " & userid, , "GetUserID()"
GetUserID = UCase(userid)

End Function

So now we know who is logged on and we can lookup their department.

Dim strUserID As String
Dim strDept As String

strUserID = GetUserID()
strDept = Nz(DLookup("[Department]", "tblUserDepts", "[UserID] = '" &
strUserId & "'"),"")

If Len(strDept) = 0 Then
MsgBox "You Do Not Have Permissions to this form"
Else
DoCmd.OpenForm "MyDepartmentForm", , , "[Department] = '" & strDept
& "'"
End If

Tasmania said:
What is the best practice in this situation? Should I use Workgroup security
or should I use some other approach? What would be any other approach? I
hope I am not asking too much? Since I am a novice Access user, please don't
be annoyed. Thanks.
--
thadi


Klatuu said:
The code I posted will show only the selected department when the form is
opened.

If you plan to use workgroup security, you could assign users to groups by
department, then set the filter based on the group of the user that is the
current user.

Tasmania said:
Thanks.
My combo is a text field and it works fine with the filtering. Thanks fir
the code.
Now how would I set up the security? If a time keeper logs in how would I
restrict them to see their specific dept data?
Thanks in advance for the response.
--
thadi


:

You would need to have the combo with all the departments on the form from
which you open the form you want to filter. Then when you open the form
Docmd.OpenForm "MyForm", , ,"[Department] = '" & Me.cboDepartment & "'"
The above is if the Department field in your table is a text field. If it
is numeric:
Docmd.OpenForm "MyForm", , ,"[Department] = " & Me.cboDepartment

:

Thanks alot for the response.
For the first part, I am using a combobox on the mainform where the user
will select the dept and it will take them to the data entry form for that
department only.

For the second part, I would like use Access Security where each timekeeper
will have a username and password with the WorkGroupInformationFile.
When database opens up, the user need to put in the userid/password, and
then it will take them to the mainform. In the mainform they will select
their department, and so on. How do I do that? Thanks again


--
thadi


:

First, the easy part.
Filter the form by department number so only that department's employees
will be included.

Now the hard part. That is, to know which department should be included.
Since I don't know enought about your applicatioin, I don't know if you are
using security or if you have any way of knowing who the user is and what
that user's deparment is. This is the part you will have to determine. The
question is "How do I know which department to filter on?"

If you can define how you will know that, I will be happy to help with the
coding of it.

:

I have a timekeeper database where one timekeeper from each department will
keep their own employee time. I need to restrict the view of data for each
department so each deprtment can see only their own peoples data. How can I
do that? At this point I am clueless since I am a novice Access User.
I appreciate all the replies.
 
G

Guest

Thanks. I have a user table where I have all the user information stored,
such as , name, dept, title, empID etc. Department do not have a individual
table. The timekeepers are also belong to the user table. Now I am really
interested setting up workgroup security. Would that be easier to set it up
from Tools - Seurity - User-Level Security Wizard, or any other way is
better? Thanks for the responses.

--
thadi


Klatuu said:
If you are new to Access, setting up workgroup security can be a little
intimidating. It would be the best solution, however.

Another way would be to create a table of users and the deparment codes they
belong to. If only certain users are able to look at the data, then only put
those users and their department codes in the table.

Then you will need to know who the logged on user is. Put this code in a
standard module:

Private Declare Function GetUserNameA Lib "Advapi32" (ByVal strN As String,
ByRef intN As Long) As Long
Public Function GetUserID()
' Gets the userid (5+2) of the current user.
' Put the following in the declarations section:
'Private Declare Function GetUserNameA Lib "Advapi32" (ByVal strN As String,
ByRef intN As Long) As Long
' modified 4/11/02 dbk set default userid for those not on network

'set default to xxx, changed 10 to 20 for length on 2 lines

Dim buffer As String * 20
Dim Length As Long
Dim lngresult As Long, userid As String

Length = 20

lngresult = GetUserNameA(buffer, Length)
If lngresult <> 0 Then
userid = Left(buffer, Length - 1)
Else
userid = "xxxxxxx"
End If
'MsgBox "USERID = " & userid, , "GetUserID()"
GetUserID = UCase(userid)

End Function

So now we know who is logged on and we can lookup their department.

Dim strUserID As String
Dim strDept As String

strUserID = GetUserID()
strDept = Nz(DLookup("[Department]", "tblUserDepts", "[UserID] = '" &
strUserId & "'"),"")

If Len(strDept) = 0 Then
MsgBox "You Do Not Have Permissions to this form"
Else
DoCmd.OpenForm "MyDepartmentForm", , , "[Department] = '" & strDept
& "'"
End If

Tasmania said:
What is the best practice in this situation? Should I use Workgroup security
or should I use some other approach? What would be any other approach? I
hope I am not asking too much? Since I am a novice Access user, please don't
be annoyed. Thanks.
--
thadi


Klatuu said:
The code I posted will show only the selected department when the form is
opened.

If you plan to use workgroup security, you could assign users to groups by
department, then set the filter based on the group of the user that is the
current user.

:

Thanks.
My combo is a text field and it works fine with the filtering. Thanks fir
the code.
Now how would I set up the security? If a time keeper logs in how would I
restrict them to see their specific dept data?
Thanks in advance for the response.
--
thadi


:

You would need to have the combo with all the departments on the form from
which you open the form you want to filter. Then when you open the form
Docmd.OpenForm "MyForm", , ,"[Department] = '" & Me.cboDepartment & "'"
The above is if the Department field in your table is a text field. If it
is numeric:
Docmd.OpenForm "MyForm", , ,"[Department] = " & Me.cboDepartment

:

Thanks alot for the response.
For the first part, I am using a combobox on the mainform where the user
will select the dept and it will take them to the data entry form for that
department only.

For the second part, I would like use Access Security where each timekeeper
will have a username and password with the WorkGroupInformationFile.
When database opens up, the user need to put in the userid/password, and
then it will take them to the mainform. In the mainform they will select
their department, and so on. How do I do that? Thanks again


--
thadi


:

First, the easy part.
Filter the form by department number so only that department's employees
will be included.

Now the hard part. That is, to know which department should be included.
Since I don't know enought about your applicatioin, I don't know if you are
using security or if you have any way of knowing who the user is and what
that user's deparment is. This is the part you will have to determine. The
question is "How do I know which department to filter on?"

If you can define how you will know that, I will be happy to help with the
coding of it.

:

I have a timekeeper database where one timekeeper from each department will
keep their own employee time. I need to restrict the view of data for each
department so each deprtment can see only their own peoples data. How can I
do that? At this point I am clueless since I am a novice Access User.
I appreciate all the replies.
 
G

Guest

Tools - Security - ect is fine.

Tasmania said:
Thanks. I have a user table where I have all the user information stored,
such as , name, dept, title, empID etc. Department do not have a individual
table. The timekeepers are also belong to the user table. Now I am really
interested setting up workgroup security. Would that be easier to set it up
from Tools - Seurity - User-Level Security Wizard, or any other way is
better? Thanks for the responses.

--
thadi


Klatuu said:
If you are new to Access, setting up workgroup security can be a little
intimidating. It would be the best solution, however.

Another way would be to create a table of users and the deparment codes they
belong to. If only certain users are able to look at the data, then only put
those users and their department codes in the table.

Then you will need to know who the logged on user is. Put this code in a
standard module:

Private Declare Function GetUserNameA Lib "Advapi32" (ByVal strN As String,
ByRef intN As Long) As Long
Public Function GetUserID()
' Gets the userid (5+2) of the current user.
' Put the following in the declarations section:
'Private Declare Function GetUserNameA Lib "Advapi32" (ByVal strN As String,
ByRef intN As Long) As Long
' modified 4/11/02 dbk set default userid for those not on network

'set default to xxx, changed 10 to 20 for length on 2 lines

Dim buffer As String * 20
Dim Length As Long
Dim lngresult As Long, userid As String

Length = 20

lngresult = GetUserNameA(buffer, Length)
If lngresult <> 0 Then
userid = Left(buffer, Length - 1)
Else
userid = "xxxxxxx"
End If
'MsgBox "USERID = " & userid, , "GetUserID()"
GetUserID = UCase(userid)

End Function

So now we know who is logged on and we can lookup their department.

Dim strUserID As String
Dim strDept As String

strUserID = GetUserID()
strDept = Nz(DLookup("[Department]", "tblUserDepts", "[UserID] = '" &
strUserId & "'"),"")

If Len(strDept) = 0 Then
MsgBox "You Do Not Have Permissions to this form"
Else
DoCmd.OpenForm "MyDepartmentForm", , , "[Department] = '" & strDept
& "'"
End If

Tasmania said:
What is the best practice in this situation? Should I use Workgroup security
or should I use some other approach? What would be any other approach? I
hope I am not asking too much? Since I am a novice Access user, please don't
be annoyed. Thanks.
--
thadi


:

The code I posted will show only the selected department when the form is
opened.

If you plan to use workgroup security, you could assign users to groups by
department, then set the filter based on the group of the user that is the
current user.

:

Thanks.
My combo is a text field and it works fine with the filtering. Thanks fir
the code.
Now how would I set up the security? If a time keeper logs in how would I
restrict them to see their specific dept data?
Thanks in advance for the response.
--
thadi


:

You would need to have the combo with all the departments on the form from
which you open the form you want to filter. Then when you open the form
Docmd.OpenForm "MyForm", , ,"[Department] = '" & Me.cboDepartment & "'"
The above is if the Department field in your table is a text field. If it
is numeric:
Docmd.OpenForm "MyForm", , ,"[Department] = " & Me.cboDepartment

:

Thanks alot for the response.
For the first part, I am using a combobox on the mainform where the user
will select the dept and it will take them to the data entry form for that
department only.

For the second part, I would like use Access Security where each timekeeper
will have a username and password with the WorkGroupInformationFile.
When database opens up, the user need to put in the userid/password, and
then it will take them to the mainform. In the mainform they will select
their department, and so on. How do I do that? Thanks again


--
thadi


:

First, the easy part.
Filter the form by department number so only that department's employees
will be included.

Now the hard part. That is, to know which department should be included.
Since I don't know enought about your applicatioin, I don't know if you are
using security or if you have any way of knowing who the user is and what
that user's deparment is. This is the part you will have to determine. The
question is "How do I know which department to filter on?"

If you can define how you will know that, I will be happy to help with the
coding of it.

:

I have a timekeeper database where one timekeeper from each department will
keep their own employee time. I need to restrict the view of data for each
department so each deprtment can see only their own peoples data. How can I
do that? At this point I am clueless since I am a novice Access User.
I appreciate all the replies.
 
G

Guest

For workgroup setup, do I need to write any code to find the user. Or that
should be taken care by Access? Thanks again for being a great help.
--
thadi


Klatuu said:
Tools - Security - ect is fine.

Tasmania said:
Thanks. I have a user table where I have all the user information stored,
such as , name, dept, title, empID etc. Department do not have a individual
table. The timekeepers are also belong to the user table. Now I am really
interested setting up workgroup security. Would that be easier to set it up
from Tools - Seurity - User-Level Security Wizard, or any other way is
better? Thanks for the responses.

--
thadi


Klatuu said:
If you are new to Access, setting up workgroup security can be a little
intimidating. It would be the best solution, however.

Another way would be to create a table of users and the deparment codes they
belong to. If only certain users are able to look at the data, then only put
those users and their department codes in the table.

Then you will need to know who the logged on user is. Put this code in a
standard module:

Private Declare Function GetUserNameA Lib "Advapi32" (ByVal strN As String,
ByRef intN As Long) As Long
Public Function GetUserID()
' Gets the userid (5+2) of the current user.
' Put the following in the declarations section:
'Private Declare Function GetUserNameA Lib "Advapi32" (ByVal strN As String,
ByRef intN As Long) As Long
' modified 4/11/02 dbk set default userid for those not on network

'set default to xxx, changed 10 to 20 for length on 2 lines

Dim buffer As String * 20
Dim Length As Long
Dim lngresult As Long, userid As String

Length = 20

lngresult = GetUserNameA(buffer, Length)
If lngresult <> 0 Then
userid = Left(buffer, Length - 1)
Else
userid = "xxxxxxx"
End If
'MsgBox "USERID = " & userid, , "GetUserID()"
GetUserID = UCase(userid)

End Function

So now we know who is logged on and we can lookup their department.

Dim strUserID As String
Dim strDept As String

strUserID = GetUserID()
strDept = Nz(DLookup("[Department]", "tblUserDepts", "[UserID] = '" &
strUserId & "'"),"")

If Len(strDept) = 0 Then
MsgBox "You Do Not Have Permissions to this form"
Else
DoCmd.OpenForm "MyDepartmentForm", , , "[Department] = '" & strDept
& "'"
End If

:

What is the best practice in this situation? Should I use Workgroup security
or should I use some other approach? What would be any other approach? I
hope I am not asking too much? Since I am a novice Access user, please don't
be annoyed. Thanks.
--
thadi


:

The code I posted will show only the selected department when the form is
opened.

If you plan to use workgroup security, you could assign users to groups by
department, then set the filter based on the group of the user that is the
current user.

:

Thanks.
My combo is a text field and it works fine with the filtering. Thanks fir
the code.
Now how would I set up the security? If a time keeper logs in how would I
restrict them to see their specific dept data?
Thanks in advance for the response.
--
thadi


:

You would need to have the combo with all the departments on the form from
which you open the form you want to filter. Then when you open the form
Docmd.OpenForm "MyForm", , ,"[Department] = '" & Me.cboDepartment & "'"
The above is if the Department field in your table is a text field. If it
is numeric:
Docmd.OpenForm "MyForm", , ,"[Department] = " & Me.cboDepartment

:

Thanks alot for the response.
For the first part, I am using a combobox on the mainform where the user
will select the dept and it will take them to the data entry form for that
department only.

For the second part, I would like use Access Security where each timekeeper
will have a username and password with the WorkGroupInformationFile.
When database opens up, the user need to put in the userid/password, and
then it will take them to the mainform. In the mainform they will select
their department, and so on. How do I do that? Thanks again


--
thadi


:

First, the easy part.
Filter the form by department number so only that department's employees
will be included.

Now the hard part. That is, to know which department should be included.
Since I don't know enought about your applicatioin, I don't know if you are
using security or if you have any way of knowing who the user is and what
that user's deparment is. This is the part you will have to determine. The
question is "How do I know which department to filter on?"

If you can define how you will know that, I will be happy to help with the
coding of it.

:

I have a timekeeper database where one timekeeper from each department will
keep their own employee time. I need to restrict the view of data for each
department so each deprtment can see only their own peoples data. How can I
do that? At this point I am clueless since I am a novice Access User.
I appreciate all the replies.
 
G

Guest

Once you have security set up, then you can get the user with CurrentUser.

Now as to the security part.
I am happy to help and I am glad you have made some progress, but when it
comes to security, it has been a long time since I used it, and I am not the
best resource for you in this area.

If you have further questions on security, I suggest you start a new post in
the security group. There are some very knowledgable people that have the
knowledge I don't.

Tasmania said:
For workgroup setup, do I need to write any code to find the user. Or that
should be taken care by Access? Thanks again for being a great help.
--
thadi


Klatuu said:
Tools - Security - ect is fine.

Tasmania said:
Thanks. I have a user table where I have all the user information stored,
such as , name, dept, title, empID etc. Department do not have a individual
table. The timekeepers are also belong to the user table. Now I am really
interested setting up workgroup security. Would that be easier to set it up
from Tools - Seurity - User-Level Security Wizard, or any other way is
better? Thanks for the responses.

--
thadi


:

If you are new to Access, setting up workgroup security can be a little
intimidating. It would be the best solution, however.

Another way would be to create a table of users and the deparment codes they
belong to. If only certain users are able to look at the data, then only put
those users and their department codes in the table.

Then you will need to know who the logged on user is. Put this code in a
standard module:

Private Declare Function GetUserNameA Lib "Advapi32" (ByVal strN As String,
ByRef intN As Long) As Long
Public Function GetUserID()
' Gets the userid (5+2) of the current user.
' Put the following in the declarations section:
'Private Declare Function GetUserNameA Lib "Advapi32" (ByVal strN As String,
ByRef intN As Long) As Long
' modified 4/11/02 dbk set default userid for those not on network

'set default to xxx, changed 10 to 20 for length on 2 lines

Dim buffer As String * 20
Dim Length As Long
Dim lngresult As Long, userid As String

Length = 20

lngresult = GetUserNameA(buffer, Length)
If lngresult <> 0 Then
userid = Left(buffer, Length - 1)
Else
userid = "xxxxxxx"
End If
'MsgBox "USERID = " & userid, , "GetUserID()"
GetUserID = UCase(userid)

End Function

So now we know who is logged on and we can lookup their department.

Dim strUserID As String
Dim strDept As String

strUserID = GetUserID()
strDept = Nz(DLookup("[Department]", "tblUserDepts", "[UserID] = '" &
strUserId & "'"),"")

If Len(strDept) = 0 Then
MsgBox "You Do Not Have Permissions to this form"
Else
DoCmd.OpenForm "MyDepartmentForm", , , "[Department] = '" & strDept
& "'"
End If

:

What is the best practice in this situation? Should I use Workgroup security
or should I use some other approach? What would be any other approach? I
hope I am not asking too much? Since I am a novice Access user, please don't
be annoyed. Thanks.
--
thadi


:

The code I posted will show only the selected department when the form is
opened.

If you plan to use workgroup security, you could assign users to groups by
department, then set the filter based on the group of the user that is the
current user.

:

Thanks.
My combo is a text field and it works fine with the filtering. Thanks fir
the code.
Now how would I set up the security? If a time keeper logs in how would I
restrict them to see their specific dept data?
Thanks in advance for the response.
--
thadi


:

You would need to have the combo with all the departments on the form from
which you open the form you want to filter. Then when you open the form
Docmd.OpenForm "MyForm", , ,"[Department] = '" & Me.cboDepartment & "'"
The above is if the Department field in your table is a text field. If it
is numeric:
Docmd.OpenForm "MyForm", , ,"[Department] = " & Me.cboDepartment

:

Thanks alot for the response.
For the first part, I am using a combobox on the mainform where the user
will select the dept and it will take them to the data entry form for that
department only.

For the second part, I would like use Access Security where each timekeeper
will have a username and password with the WorkGroupInformationFile.
When database opens up, the user need to put in the userid/password, and
then it will take them to the mainform. In the mainform they will select
their department, and so on. How do I do that? Thanks again


--
thadi


:

First, the easy part.
Filter the form by department number so only that department's employees
will be included.

Now the hard part. That is, to know which department should be included.
Since I don't know enought about your applicatioin, I don't know if you are
using security or if you have any way of knowing who the user is and what
that user's deparment is. This is the part you will have to determine. The
question is "How do I know which department to filter on?"

If you can define how you will know that, I will be happy to help with the
coding of it.

:

I have a timekeeper database where one timekeeper from each department will
keep their own employee time. I need to restrict the view of data for each
department so each deprtment can see only their own peoples data. How can I
do that? At this point I am clueless since I am a novice Access User.
I appreciate all the replies.
 
G

Guest

Thanks a lot
--
thadi


Klatuu said:
Once you have security set up, then you can get the user with CurrentUser.

Now as to the security part.
I am happy to help and I am glad you have made some progress, but when it
comes to security, it has been a long time since I used it, and I am not the
best resource for you in this area.

If you have further questions on security, I suggest you start a new post in
the security group. There are some very knowledgable people that have the
knowledge I don't.

Tasmania said:
For workgroup setup, do I need to write any code to find the user. Or that
should be taken care by Access? Thanks again for being a great help.
--
thadi


Klatuu said:
Tools - Security - ect is fine.

:

Thanks. I have a user table where I have all the user information stored,
such as , name, dept, title, empID etc. Department do not have a individual
table. The timekeepers are also belong to the user table. Now I am really
interested setting up workgroup security. Would that be easier to set it up
from Tools - Seurity - User-Level Security Wizard, or any other way is
better? Thanks for the responses.

--
thadi


:

If you are new to Access, setting up workgroup security can be a little
intimidating. It would be the best solution, however.

Another way would be to create a table of users and the deparment codes they
belong to. If only certain users are able to look at the data, then only put
those users and their department codes in the table.

Then you will need to know who the logged on user is. Put this code in a
standard module:

Private Declare Function GetUserNameA Lib "Advapi32" (ByVal strN As String,
ByRef intN As Long) As Long
Public Function GetUserID()
' Gets the userid (5+2) of the current user.
' Put the following in the declarations section:
'Private Declare Function GetUserNameA Lib "Advapi32" (ByVal strN As String,
ByRef intN As Long) As Long
' modified 4/11/02 dbk set default userid for those not on network

'set default to xxx, changed 10 to 20 for length on 2 lines

Dim buffer As String * 20
Dim Length As Long
Dim lngresult As Long, userid As String

Length = 20

lngresult = GetUserNameA(buffer, Length)
If lngresult <> 0 Then
userid = Left(buffer, Length - 1)
Else
userid = "xxxxxxx"
End If
'MsgBox "USERID = " & userid, , "GetUserID()"
GetUserID = UCase(userid)

End Function

So now we know who is logged on and we can lookup their department.

Dim strUserID As String
Dim strDept As String

strUserID = GetUserID()
strDept = Nz(DLookup("[Department]", "tblUserDepts", "[UserID] = '" &
strUserId & "'"),"")

If Len(strDept) = 0 Then
MsgBox "You Do Not Have Permissions to this form"
Else
DoCmd.OpenForm "MyDepartmentForm", , , "[Department] = '" & strDept
& "'"
End If

:

What is the best practice in this situation? Should I use Workgroup security
or should I use some other approach? What would be any other approach? I
hope I am not asking too much? Since I am a novice Access user, please don't
be annoyed. Thanks.
--
thadi


:

The code I posted will show only the selected department when the form is
opened.

If you plan to use workgroup security, you could assign users to groups by
department, then set the filter based on the group of the user that is the
current user.

:

Thanks.
My combo is a text field and it works fine with the filtering. Thanks fir
the code.
Now how would I set up the security? If a time keeper logs in how would I
restrict them to see their specific dept data?
Thanks in advance for the response.
--
thadi


:

You would need to have the combo with all the departments on the form from
which you open the form you want to filter. Then when you open the form
Docmd.OpenForm "MyForm", , ,"[Department] = '" & Me.cboDepartment & "'"
The above is if the Department field in your table is a text field. If it
is numeric:
Docmd.OpenForm "MyForm", , ,"[Department] = " & Me.cboDepartment

:

Thanks alot for the response.
For the first part, I am using a combobox on the mainform where the user
will select the dept and it will take them to the data entry form for that
department only.

For the second part, I would like use Access Security where each timekeeper
will have a username and password with the WorkGroupInformationFile.
When database opens up, the user need to put in the userid/password, and
then it will take them to the mainform. In the mainform they will select
their department, and so on. How do I do that? Thanks again


--
thadi


:

First, the easy part.
Filter the form by department number so only that department's employees
will be included.

Now the hard part. That is, to know which department should be included.
Since I don't know enought about your applicatioin, I don't know if you are
using security or if you have any way of knowing who the user is and what
that user's deparment is. This is the part you will have to determine. The
question is "How do I know which department to filter on?"

If you can define how you will know that, I will be happy to help with the
coding of it.

:

I have a timekeeper database where one timekeeper from each department will
keep their own employee time. I need to restrict the view of data for each
department so each deprtment can see only their own peoples data. How can I
do that? At this point I am clueless since I am a novice Access User.
I appreciate all the replies.
 

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