My subform contains several combo boxes and text boxes. Users will enter data into all these fields. I want to place a command button on the subform so that when it's clicked, all the fields on the subform are locked. Can this be done?
I was reading your response to mrbboy today that wants to place a command button on the subform so that when it's clicked, all the fields on the subform are locked.
You replied Yes, you can loop thru all controls and set their LOCKED property to TRUE.. I have a similar need, but what I also need is a command button when clicked un-locks the combo boxes and text boxes so information can be edited. Then re-lock the combo boxes and text boxes when I’m finished.
Be aware . . . although setting the [blue]Locked[/blue] property of controls prevents editing/deleting data of said controls, it [blue]doesn't prevent deletion of the currently selected record![/blue]
You may want to give a little more thought here . . .
Also, it doesn't lock them forever. Next time you open the form, they'll be unlocked. You'd then want to put code in your Form's OnOpen event that maybe opens the form where ALLOW EDITS = False or locks certain controls. Depends on what you are looking for. The only time any of my customers has requested this is to protect themselves from themselves: they don't want to make a mistake. And like Aceman says, they can still get into the data if they really want to. "Locking" is just an illusion. If I want to "keep people out" then I have a secure server that doesn't allow them in; Or only allow users in to look but not touch. A variety of solutions depending on what you are really looking for.
By the way, MikeFL...just set the LOCKED property in the code above to FALSE
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244. Basics at
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.