If field is UserReadOnly then make all forms read only

D

deb

I have a table called tblVersion with a field called User_ReadOnly. If
User_ReadOnly is "UserReadOnly" the I do not want the user to be able to
add, edit or delete any data.

If DLookup("[User_ReadOnly]", "[tblVersion]", "[UserID] = '" &
Environ("username") & "'") = "UserReadOnly" Then

Make all forms (main form and subform 1 and 2) read only.
fProject, fDeliv, fTrans are my forms.

What is the best approach to this?
I am not sure where to begin.

Thanks
 
A

Arvin Meyer [MVP]

You could use the following code to lock all, or some controls on the form,
or as many forms as you want:

http://www.datastrat.com/Code/LockIt.txt

Similar code can also be written to unlock those controls. Notice that the
Tag property of a control can be used to selectively lock or disable
controls.
 
D

deb

Looks like what I need, but how do I use this?

I do appreciate your help!!


--
deb


Arvin Meyer said:
You could use the following code to lock all, or some controls on the form,
or as many forms as you want:

http://www.datastrat.com/Code/LockIt.txt

Similar code can also be written to unlock those controls. Notice that the
Tag property of a control can be used to selectively lock or disable
controls.
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com


deb said:
I have a table called tblVersion with a field called User_ReadOnly. If
User_ReadOnly is "UserReadOnly" the I do not want the user to be able to
add, edit or delete any data.

If DLookup("[User_ReadOnly]", "[tblVersion]", "[UserID] = '" &
Environ("username") & "'") = "UserReadOnly" Then

Make all forms (main form and subform 1 and 2) read only.
fProject, fDeliv, fTrans are my forms.

What is the best approach to this?
I am not sure where to begin.

Thanks
 
D

deb

Arvin,

I pasted this code into my form and then in the On_Load area I tried to call
by using:

Call Lockit
Lockit
and
form_fProject.Lockit

I get compile error
Argument not optional


PLEASE help!!!
--
deb


Arvin Meyer said:
You could use the following code to lock all, or some controls on the form,
or as many forms as you want:

http://www.datastrat.com/Code/LockIt.txt

Similar code can also be written to unlock those controls. Notice that the
Tag property of a control can be used to selectively lock or disable
controls.
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com


deb said:
I have a table called tblVersion with a field called User_ReadOnly. If
User_ReadOnly is "UserReadOnly" the I do not want the user to be able to
add, edit or delete any data.

If DLookup("[User_ReadOnly]", "[tblVersion]", "[UserID] = '" &
Environ("username") & "'") = "UserReadOnly" Then

Make all forms (main form and subform 1 and 2) read only.
fProject, fDeliv, fTrans are my forms.

What is the best approach to this?
I am not sure where to begin.

Thanks
 
A

Arvin Meyer [MVP]

You have to tell it which form. Assuming that you put the code in a standard
module (which you should) from the form's current event, or in your case in
the form's Open or Load event, you'd use:

LockIt(Me)

So:

Sub Form_Open()
If DLookup("[User_ReadOnly]", "[tblVersion]", "[UserID] = '" &
Environ("username") & "'") = "UserReadOnly" Then
LockIt(Me)
End If
End Sub

--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com


deb said:
Arvin,

I pasted this code into my form and then in the On_Load area I tried to
call
by using:

Call Lockit
Lockit
and
form_fProject.Lockit

I get compile error
Argument not optional


PLEASE help!!!
--
deb


Arvin Meyer said:
You could use the following code to lock all, or some controls on the
form,
or as many forms as you want:

http://www.datastrat.com/Code/LockIt.txt

Similar code can also be written to unlock those controls. Notice that
the
Tag property of a control can be used to selectively lock or disable
controls.
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com


deb said:
I have a table called tblVersion with a field called User_ReadOnly. If
User_ReadOnly is "UserReadOnly" the I do not want the user to be able
to
add, edit or delete any data.

If DLookup("[User_ReadOnly]", "[tblVersion]", "[UserID] = '" &
Environ("username") & "'") = "UserReadOnly" Then

Make all forms (main form and subform 1 and 2) read only.
fProject, fDeliv, fTrans are my forms.

What is the best approach to this?
I am not sure where to begin.

Thanks
 
D

Douglas J. Steele

I'd recommend using the code in http://www.mvps.org/access/api/api0008.htm
at "The Access Web" rather than Environ("username") since it would be
trivial for a nefarious user to get around that code by resetting his/her
environment variable.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Arvin Meyer said:
You have to tell it which form. Assuming that you put the code in a
standard module (which you should) from the form's current event, or in
your case in the form's Open or Load event, you'd use:

LockIt(Me)

So:

Sub Form_Open()
If DLookup("[User_ReadOnly]", "[tblVersion]", "[UserID] = '" &
Environ("username") & "'") = "UserReadOnly" Then
LockIt(Me)
End If
End Sub

--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com


deb said:
Arvin,

I pasted this code into my form and then in the On_Load area I tried to
call
by using:

Call Lockit
Lockit
and
form_fProject.Lockit

I get compile error
Argument not optional


PLEASE help!!!
--
deb


Arvin Meyer said:
You could use the following code to lock all, or some controls on the
form,
or as many forms as you want:

http://www.datastrat.com/Code/LockIt.txt

Similar code can also be written to unlock those controls. Notice that
the
Tag property of a control can be used to selectively lock or disable
controls.
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com


I have a table called tblVersion with a field called User_ReadOnly. If
User_ReadOnly is "UserReadOnly" the I do not want the user to be able
to
add, edit or delete any data.

If DLookup("[User_ReadOnly]", "[tblVersion]", "[UserID] = '" &
Environ("username") & "'") = "UserReadOnly" Then

Make all forms (main form and subform 1 and 2) read only.
fProject, fDeliv, fTrans are my forms.

What is the best approach to this?
I am not sure where to begin.

Thanks
 
A

Arvin Meyer [MVP]

I would too. Since he already had been working satisfactorily with Environ,
I used his existing code. Simply copy the code and save to a standard
module, then replace:

Environ("username")

with:

fOSUserName()

and his code should work.
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com


Douglas J. Steele said:
I'd recommend using the code in http://www.mvps.org/access/api/api0008.htm
at "The Access Web" rather than Environ("username") since it would be
trivial for a nefarious user to get around that code by resetting his/her
environment variable.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Arvin Meyer said:
You have to tell it which form. Assuming that you put the code in a
standard module (which you should) from the form's current event, or in
your case in the form's Open or Load event, you'd use:

LockIt(Me)

So:

Sub Form_Open()
If DLookup("[User_ReadOnly]", "[tblVersion]", "[UserID] = '" &
Environ("username") & "'") = "UserReadOnly" Then
LockIt(Me)
End If
End Sub

--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com


deb said:
Arvin,

I pasted this code into my form and then in the On_Load area I tried to
call
by using:

Call Lockit
Lockit
and
form_fProject.Lockit

I get compile error
Argument not optional


PLEASE help!!!
--
deb


:

You could use the following code to lock all, or some controls on the
form,
or as many forms as you want:

http://www.datastrat.com/Code/LockIt.txt

Similar code can also be written to unlock those controls. Notice that
the
Tag property of a control can be used to selectively lock or disable
controls.
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com


I have a table called tblVersion with a field called User_ReadOnly.
If
User_ReadOnly is "UserReadOnly" the I do not want the user to be
able to
add, edit or delete any data.

If DLookup("[User_ReadOnly]", "[tblVersion]", "[UserID] = '" &
Environ("username") & "'") = "UserReadOnly" Then

Make all forms (main form and subform 1 and 2) read only.
fProject, fDeliv, fTrans are my forms.

What is the best approach to this?
I am not sure where to begin.

Thanks
 

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