By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,495 Members | 1,231 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,495 IT Pros & Developers. It's quick & easy.

locking form controls

P: 5
i want to add to a button to the form to lock/unlock the controls, so that nobody accidentally changes the data. In one form i had the controls to be locked in a subform so i just locked it through the change property, but in the main there are several controls and changing the property of every control is not possible, so is there any other way to lock the controls of the form, i tried changing the recordset to snapshot, but i think i can't handle the recordset properly
so i am left with no result. Please any body help, how can i lock the controls on the form.

thanks in advance
Jan 5 '12 #1

✓ answered by Rabbit

You can either use a loop to lock all the controls. Or put the main form into a subform and lock that.

Share this Question
Share on Google+
5 Replies


Rabbit
Expert Mod 10K+
P: 12,315
You can either use a loop to lock all the controls. Or put the main form into a subform and lock that.
Jan 5 '12 #2

P: 5
how to loop the controls. please tell, as i am novice and dont know much about programming.
Jan 7 '12 #3

Rabbit
Expert Mod 10K+
P: 12,315
You can use the for each construct to loop through all the controls in the Form.Controls collection.
Jan 8 '12 #4

P: 5
sorry i didnt get what you said...
Jan 9 '12 #5

NeoPa
Expert Mod 15k+
P: 31,186
Ashwinidubey:
sorry i didnt get what you said...
You don't say which part was unclear, which rather implies all of it is. This would indicate you have almost no experience in Access VBA. Something you should mention if you don't want all replies to go over your head.

What Rabbit is referring to is a basic For Each loop construct in your code something like :
Expand|Select|Wrap|Line Numbers
  1. Dim ctl As Control
  2.  
  3. For Each ctl In Me.Controls
  4.     ctl.Locked = True
  5. Next ctl
This won't work directly as some controls won't have a .Locked property, but it illustrates the concept. Also you didn't indicate in your question how you might determine the controls you're interested in so I couldn't include that in any example code obviously (I would hope).
Jan 9 '12 #6

Post your reply

Sign in to post your reply or Sign up for a free account.