Reputation: 94
I have a form is reading data with a one to many relationship. In the form I have 5 columns. Each field is manipulable originally. But I want the individual rows to lock after data in column 4 and 5 are filled in. Effectively finishing the record. I have been able to figure out how to close the entire form down, but not individual rows/records.
Here is the code I am using.
If IsNullorEmpty(GPInterfaceID) Then
Me.ChargeType.Locked = True
Else
Me.ChargeType.Locked = False
End If
If IsNullorEmpty(GPPostingDate) Then
Me.ChargeType.Locked = True
Else
Me.ChargeType.Locked = False
End If
This is the version of the code where I tried locking the individual columns individually. I also tried locking all of them at once.
I am not fluent in VB at all. So any assistance would be appreciated.
Upvotes: 2
Views: 210
Reputation: 2787
You can do something like this:
Private Sub Form_Current()
If IsNullorEmpty(GPInterfaceID) Then
Me.ChargeType.Locked = True
End If
End Sub
The event will fire every time you select a row. If in the selected row GPInterfaceID is empty then Access will lock the field ChargeType. In that moment Access will lock that field in every row but that does not matter because in the moment you click on another row Access will fire the Form_Current() event again and will lock or unlock the field(s).
Upvotes: 1