Wrox Home  
Search P2P Archive for: Go

  Return to Index  

access thread: Lock/Unlock Fields


Message #1 by "George Oro" <george@c...> on Sat, 18 May 2002 09:01:02 +0400
Hi Guys,

I used to lock all my fields on my data entry form to avoid accidental updating then I assign to a Macro to Unlock/Lock all fields.
I'm doing this for my security purposes, co'z only User1 is only allowed to edit record in this area. Unfortunately, I can't remove
some User2 access to the source table of this form because in some area or part of the table User2 should have the access to update
the recordset. Therefore, I assign User1 to have the access to run the macro and nothing for User2. This is working fine, but it is
quite pain for assigning to the macro to unlock/lock one by one all the fields (30+ no. of fields).

Is there any short method to Lock/Unlock my fields and give permission to specific users only?


Any help and tips is highly appreciated...


Cheers,
George





Message #2 by "Randy Cornish" <rlcornish@c...> on Sun, 19 May 2002 21:05:14
If your form has an "OK" or "Commit" button of some kind to perform the 
update, just disable that button (and menu item if you have menus as 
well).

R

> Hi Guys,

I used to lock all my fields on my data entry form to avoid accidental 
updating then I assign to a Macro to Unlock/Lock all fields.
I'm doing this for my security purposes, co'z only User1 is only allowed 
to edit record in this area. Unfortunately, I can't remove
some User2 access to the source table of this form because in some area 
or part of the table User2 should have the access to update
the recordset. Therefore, I assign User1 to have the access to run the 
macro and nothing for User2. This is working fine, but it is
quite pain for assigning to the macro to unlock/lock one by one all the 
fields (30+ no. of fields).

Is there any short method to Lock/Unlock my fields and give permission to 
specific users only?


Any help and tips is highly appreciated...


Cheers,
George





`
Message #3 by "Amy Wyatt" <amyw@c...> on Mon, 20 May 2002 13:36:01
I would suggest doing it in a loop in VBA where you access each control on 
the form and set its properties based on the User type sent to the 
function. Following is a simple example:

    Dim frm as Form
    Dim ctrl as Control
    
    Set frm = Me.Form
    
    For Each ctrl in frm.Controls
         ctrl.Locked=False
    Next ctrl

You can set a variable for both Mode (Lock On or Off) and one for user 
type (All or Some) and then use Case statements to do the various locking 
or unlocking. Be aware that if you have labels and other non-lockable 
controls you can either use the 'dangerous' On Error Resume Next statement 
to over ride errors or, the better choice, check what kind of control is 
currently accessed (i.e. ctrl.ControlType = acTextBox) before applying the 
lock.

Good luck.

Amy


> If your form has an "OK" or "Commit" button of some kind to perform the 
u> pdate, just disable that button (and menu item if you have menus as 
w> ell).

> R

> > Hi Guys,

> I used to lock all my fields on my data entry form to avoid accidental 
u> pdating then I assign to a Macro to Unlock/Lock all fields.
I> 'm doing this for my security purposes, co'z only User1 is only allowed 
t> o edit record in this area. Unfortunately, I can't remove
s> ome User2 access to the source table of this form because in some area 
o> r part of the table User2 should have the access to update
t> he recordset. Therefore, I assign User1 to have the access to run the 
m> acro and nothing for User2. This is working fine, but it is
q> uite pain for assigning to the macro to unlock/lock one by one all the 
f> ields (30+ no. of fields).

> Is there any short method to Lock/Unlock my fields and give permission 
to 
s> pecific users only?

> 
A> ny help and tips is highly appreciated...

> 
C> heers,
G> eorge

> 

> 

Message #4 by "George Oro" <george@c...> on Mon, 20 May 2002 17:35:43 +0400
Hi Amy,

Many thanks for the very nice tips.


Cheers,
George

-----Original Message-----
From: Amy Wyatt [mailto:amyw@c...]
Sent: Monday, May 20, 2002 1:36 PM
To: Access
Subject: [access] Re: Lock/Unlock Fields


I would suggest doing it in a loop in VBA where you access each control on 
the form and set its properties based on the User type sent to the 
function. Following is a simple example:

    Dim frm as Form
    Dim ctrl as Control
    
    Set frm = Me.Form
    
    For Each ctrl in frm.Controls
         ctrl.Locked=False
    Next ctrl

You can set a variable for both Mode (Lock On or Off) and one for user 
type (All or Some) and then use Case statements to do the various locking 
or unlocking. Be aware that if you have labels and other non-lockable 
controls you can either use the 'dangerous' On Error Resume Next statement 
to over ride errors or, the better choice, check what kind of control is 
currently accessed (i.e. ctrl.ControlType = acTextBox) before applying the 
lock.

Good luck.

Amy


> If your form has an "OK" or "Commit" button of some kind to perform the 
u> pdate, just disable that button (and menu item if you have menus as 
w> ell).

> R

> > Hi Guys,

> I used to lock all my fields on my data entry form to avoid accidental 
u> pdating then I assign to a Macro to Unlock/Lock all fields.
I> 'm doing this for my security purposes, co'z only User1 is only allowed 
t> o edit record in this area. Unfortunately, I can't remove
s> ome User2 access to the source table of this form because in some area 
o> r part of the table User2 should have the access to update
t> he recordset. Therefore, I assign User1 to have the access to run the 
m> acro and nothing for User2. This is working fine, but it is
q> uite pain for assigning to the macro to unlock/lock one by one all the 
f> ields (30+ no. of fields).

> Is there any short method to Lock/Unlock my fields and give permission 
to 
s> pecific users only?

> 
A> ny help and tips is highly appreciated...

> 
C> heers,
G> eorge

> 

> 



  Return to Index