From: Kelly on 15 Jan 2010 10:06 Need assistance from the experts. I used the following code to lock the fields in a subform per a request. Now I have been request to lock all the fields except two in the sub form and I am not sure how to handle this. I tried enabled on the different fields but that did not correct the problem. The goal is to enter data for that record and once an authorization date is entered it would lock the record. Is there a way to allowedits and lock it back if someone needs to change the field StructureKeymark? Thanks in advance to assistance. This is just a few lines for the main fields I'm trying to address Option Compare Database Private Sub StructureApprovedDate_Enter() If IsNull([StructureApprovedDate]) Then Form.AllowEdits = True Else Form.AllowEdits = False End If End Sub Private Sub StructureKeymark_Enter() If IsNull([StructureApprovedDate]) Then Form.AllowEdits = True Else Form.AllowEdits = False End If End Sub Kelly
From: BruceM via AccessMonster.com on 15 Jan 2010 10:51 You lock controls, not fields. If you do not allow edits, I doubt it makes any difference whether a control is locked (or enabled) or not. Why not just lock controls other than the two, using the control properties? Then make a function something like this: Private Function LockCtls() Me.Text1.Locked = Not IsNull(Me.txtAuthDate) And Not IsNull(Me.Text1) Me.txtAuthDate.Locked = Me.Text1.Locked End Function In the After Update event of each of the two controls and in the form's Current event: Call LockCtls() If you allow zero-length strings in the text field you may need to do: Private Function LockCtls() Me.Text1.Locked = Not IsNull(Me.txtAuthDate) And Nz(Me.Text1,"") = "" Me.txtAuthDate.Locked = Me.Text1.Locked End Function I can't help wondering what the rest of the controls are that they need to be locked all the time. Do they ever receive data? Kelly wrote: >Need assistance from the experts. I used the following code to lock the >fields in a subform per a request. Now I have been request to lock all the >fields except two in the sub form and I am not sure how to handle this. I >tried enabled on the different fields but that did not correct the problem. >The goal is to enter data for that record and once an authorization date is >entered it would lock the record. Is there a way to allowedits and lock it >back if someone needs to change the field StructureKeymark? Thanks in advance >to assistance. > >This is just a few lines for the main fields I'm trying to address > >Option Compare Database >Private Sub StructureApprovedDate_Enter() >If IsNull([StructureApprovedDate]) Then > Form.AllowEdits = True >Else > Form.AllowEdits = False >End If >End Sub > >Private Sub StructureKeymark_Enter() >If IsNull([StructureApprovedDate]) Then > Form.AllowEdits = True >Else > Form.AllowEdits = False >End If >End Sub > >Kelly -- Message posted via http://www.accessmonster.com
|
Pages: 1 Prev: Strange Date Next: Curious Reaction to subform SQL statement |