From: SamMexico on 12 Apr 2010 11:35 Hello everyone, I was wondering whether anyone out there could please help me? I am a complete novice concerning MS Access. I have recently managed to create a database using 2003 and have made some headway but I am stuck on one particular issue: When accessing the various forms I would like the text boxes that already contain data to be locked (this varies from record to record though...) so that no one can alter them whilst the empty text boxes are editable (and then locked/protected) once I have entered the relevant data. Is there a simple way (step by step please as I really haven't got a clue :) ) of doing this? Any help would be greatly appreciated, Sam
From: Dirk Goldgar on 12 Apr 2010 11:58 "SamMexico" <u59312(a)uwe> wrote in message news:a66d00c0f54e6(a)uwe... > Hello everyone, I was wondering whether anyone out there could please help > me? > I am a complete novice concerning MS Access. I have recently managed to > create a database using 2003 and have made some headway but I am stuck on > one > particular issue: > > When accessing the various forms I would like the text boxes that already > contain data to be locked (this varies from record to record though...) > so > that no one can alter them whilst the empty text boxes are editable (and > then > locked/protected) once I have entered the relevant data. > > Is there a simple way (step by step please as I really haven't got a clue > :) ) > of doing this? > > Any help would be greatly appreciated, This is easy enough to program, but problematic in practice. What you would do is, in the form's Current event, set the Locked property for all data-entry controls according to whether or not the control's value is Null. E.g, '------ start of example code ------ Private Sub Form_Current() Me.txtTextbox1.Locked = Not IsNull(Me.txtTextbox1) Me.txtTextbox2.Locked = Not IsNull(Me.txtTextbox2) Me.txtTextbox3.Locked = Not IsNull(Me.txtTextbox3) ' ... etc. End Sub '------ end of example code ------ But what happens if an incorrect entry was made in a record that has already been saved? You can no longer go back to correct it. I suppose you could have an "unlock" button, that would have code to unlock all the controls. -- Dirk Goldgar, MS Access MVP Access tips: www.datagnostics.com/tips.html (please reply to the newsgroup)
From: Linq Adams via AccessMonster.com on 12 Apr 2010 14:05 Dirk raises a point that novices frequently overlook in doing this sort of thing! Mistakes are going to happen! That's one of the certainly in programming life! Most users, in my experience, don't realize that labels have an Click and Double Click event, so what I usually do is tie code to one of these events on a label on the form, usually the form title label, to unlock all controls. Authorized persons can easily make the correction then move to another record. Having the code Dirk gave you in the OnCurrent event assures that when this is done the controls are once again locked, if appropriate. -- There's ALWAYS more than one way to skin a cat! Answers/posts based on Access 2000/2003 Message posted via http://www.accessmonster.com
From: Data Gopher on 12 Apr 2010 23:05 Hi Sam, You can try something like this. If not isnull(me!YourFieldName) Then Me!YourFieldName.Enabled=False end if -- Dan "SamMexico" wrote: > Hello everyone, I was wondering whether anyone out there could please help me? > I am a complete novice concerning MS Access. I have recently managed to > create a database using 2003 and have made some headway but I am stuck on one > particular issue: > > When accessing the various forms I would like the text boxes that already > contain data to be locked (this varies from record to record though...) so > that no one can alter them whilst the empty text boxes are editable (and then > locked/protected) once I have entered the relevant data. > > Is there a simple way (step by step please as I really haven't got a clue :) ) > of doing this? > > Any help would be greatly appreciated, > > Sam > > . >
From: SamMexico via AccessMonster.com on 13 Apr 2010 04:11
Thanks Dan, sorry to be a complete nugget but where exactly do I put that code? Cheers, Sam -- Message posted via http://www.accessmonster.com |