I have some VBA that I wrote a while back when I first started working in Access, and I'm trying to find if there is a better way of doing this.
On my form I have a set of fields that can be displayed as editable or read-only depending on a "Lockout" checkbox for that record.
But it feels like a lot of typing for something so simple. Is there an easier way of doing this? If not, would it be smarter to create a function to do this? As it stands I'm assuming I would have to have this code run when the form loads, when the Lockout box is clicked, and whenever the record is changed just to ensure that the records are displayed as locked or unlocked appropriately.
Here's what I have:
Thanks.
On my form I have a set of fields that can be displayed as editable or read-only depending on a "Lockout" checkbox for that record.
But it feels like a lot of typing for something so simple. Is there an easier way of doing this? If not, would it be smarter to create a function to do this? As it stands I'm assuming I would have to have this code run when the form loads, when the Lockout box is clicked, and whenever the record is changed just to ensure that the records are displayed as locked or unlocked appropriately.
Here's what I have:
Code:
Private Sub Lockout_Click()
If [Lockout] = True Then
Me![Customer_Text].Enabled = False
Me![ReqDesc_Text].Enabled = False
Me![MoreInfo_Text].Enabled = False
Me![ReqType_Combo].Enabled = False
Me![PhoneNum_Text].Enabled = False
Me![WorkedBy_Combo].Enabled = False
Me![UserID_Text].Enabled = False
Me![Man#_Text].Enabled = False
Me![ReqDate_Text].Enabled = False
Me![CompDate_Text].Enabled = False
Me![Count_Text].Enabled = False
Else
Me![Customer_Text].Enabled = True
Me![ReqDesc_Text].Enabled = True
Me![MoreInfo_Text].Enabled = True
Me![ReqType_Combo].Enabled = True
Me![PhoneNum_Text].Enabled = True
Me![WorkedBy_Combo].Enabled = True
Me![UserID_Text].Enabled = True
Me![Man#_Text].Enabled = True
Me![ReqDate_Text].Enabled = True
Me![CompDate_Text].Enabled = True
Me![Count_Text].Enabled = True
End If
End Sub
Thanks.