View Single Post
  #27  
Old February 2nd, 2009, 01:39 AM posted to microsoft.public.access.forms,microsoft.public.access.formscoding
Gina Whipp
external usenet poster
 
Posts: 3,500
Default MISTAKE: navigating to different records in a read only form

Paul,

I found something I got from Dirk Goldgar back in 2005 that might even work
better for allowing locking of controls. The below does not lok unbound
fields or caculated fields but in combination with the Security table it
might give you wnat you desire.

I have a form frmLogOn and everyone has their one front end. My table
consists of

tblSecurity
sSecurityID sSecurityLevel
1 Edit
2 View (or Read Only)
13 System Administrator

frmLogOn has four fields, apAssociateID, apPassword, apLogOn, apSecurityID
and goes invisible after they enter the correct Password.

Their End-Users log on, password and security level is stored in
tblAssociatesProfile. Then you can use this in the On_Current event of your
form

If [Forms]![frmLogOn]![txtSecurityID] = 2 Then
fncLockUnlockControls Me, True
Else
fncLockUnlockControls Me, False
End If

***** Copy in a module window but do not name module the same as the
Function.
Public Function fncLockUnlockControls(frm As Form, LockIt As Boolean)
'Lock or unlock all data-bound controls on form,
'depending on the value of LockIt: True = lock; False = unlock.

On Error GoTo Err_fncLockUnlockControls
Const conERR_NO_PROPERTY = 438

Dim ctl As Control

For Each ctl In frm.Controls
With ctl
If Left(.ControlSource & "=", 1) "=" Then
.Locked = LockIt
.Enabled = True
End If
End With
Skip_Control: 'come here from error if no .ControlSource property
Next ctl

Exit_fncLockUnlockControls:
Exit Function

Err_fncLockUnlockControls:
If Err.Number = conERR_NO_PROPERTY Then
Resume Skip_Control
Else
MsgBox "Error " & Err.Number & ": " & Err.Description
Resume Exit_fncLockUnlockControls
End If

End Function


--
Gina Whipp

"I feel I have been denied critical, need to know, information!" - Tremors
II

http://www.regina-whipp.com/index_files/TipList.htm

"Paul" wrote in message
...
Thanks for the comments, Gina.

As I mentioned to Dirk in my message of 1/31 5:34 PM, all users can edit
some records in this form's recordset, but not all. Please see that
message form more detail.

I do have a question regarding your Security Table. Is this something you
use as part of the built-in Access security? I've always avoided getting
into Access Security because I've read that it "ranges from the
labyrinthine to the inscrutable."

If it's not part of the built in Access Security, and if it's simply a
table you're using to establish user security levels, could you say a few
more words about how you're using it? For example, are you using
DLookup() in VBA to get into your security table to check authorization
levels?

Paul