where as <field name> is replaced useing the name of the text box control to be unlocked.
I must say though in a normal form this would probably cause you to create a lot of buttons and probably crowed the form. Maybe it would be better to use just one button that unlocks all of the fields or use a double click event on the control of the field to be edited.
Also you might want to create a procedure on some event of your choice, perhaps an on click event for a button that you have created to change records. In order to re-lock the fields so that the user can't edit the field until the unlock button is clicked agian. Other wise once you unlock the control it will stay unlocked until the form is closed. To do this simply use the same code again swapping the true and false.
What TMC said is true. I have a database with a form that I set to be not editable when opened, however, the user can select the EditForm CommandButton to make the form editable. After the form is either Saved or Exited the code reverts it back to the non-editable status. Below are three different events I have that accomplish this for me.
Private Sub Form_Current() 'Set to non-editable status when it opens.
Me.AllowEdits = False ' Set the form to its read-only state.
cboStudentID = StudentID ' Update the Find Record combo box.
Private Sub EditRecord_Click() 'Behind the EditRecord command button.
Me.AllowEdits = True 'jThe form is now editable
FirstName.SetFocus ' Move to the FirstName Field
Private Sub Form_AfterUpdate() 'Code for forms AfterUpdate event
Me.AllowEdits = False ' Return the form to its read-only state.
MsgBox "This record is now saved."
It works smooth and clean and never know it's there. With CommandButtons on EACH field would be cause for too much and would look crowded as TMC stated. There are other ways I'm sure but this works good for me and have never had a problem.
hope this offers some kinda help
have a nice one,
Just glad you found something that would work for you. And as you know, that is what we offer, advice, suggestions, tips. But then, depending on the individual there are sometimes many ways to achieve the same goal. I am familiar with what you are talking about though in the web programming arena and have seen a few forms like that. Now, it wasn't said you just Can't use multiple buttons to do that, just that it would seemingly crowd the form, thereby looking a bit cluttered. However, you can create such buttons and then adjust them to a very small size, looking almost like a small icon. In that case the easiest thing to do from that standpoint would be to create all of the buttons and place them logically as you would in web programming. Then, create a Function that would simply just say to Unlock/Enable that field when the CommandButton is clicked. Though I haven't done so myself, there is a way to create it so that it will somehow read into it just what field you are in when you click it, without having to actually name each field.
I will look into that for you and see if I can find a way. Unless someone else gets it for you. So hey, don't give up until YOU are totally satisfied with the end results. But also, always keep in mind, IF you are designing something that others/end users will be using, think Logic, Simplistic, or KISS.
I was doing a search for something completely unrelated to this subject and saw that Bud has posted a reply (which I never saw when I posted this message).
I just wanted to say thank you once again. I always enjoy going to the friendly forums where people try and help one another, giving constructive criticism and not making comments that steer people away from the help they may sorely need.
In all honesty I wish I could still be programming everything in PHP because that is what I am most comforatable with but now that I've been programming in VBA with all of these neat components I've been enjoying Access quite a bit. In the spirit of enjoying it I've started making an Access db that stores all of the information for my wedding (can't be anal retentive enough sometimes).
And you're welcome and thanks also for your nice comments. That's what it's all about. If we can help each other then it's a good thing. So you hang in here with us and feel free to jump right in when you have a solution that someone needs. More than one way to skin a cat without getting scratched...hahaha.... (Ouch!!!!!#@$@# freakin cat just ....oh...never mind....LOL)