Locking a subform using vb

sloaner14

Registered User.
Local time
Today, 14:38
Joined
Apr 25, 2002
Messages
32
I need help with code. I am just learning vb. I have a form named frmCustomers with a subform names subfrmTrans. In the main form I have a check box that I want to control the locking and unlocking of the subform. I can write code that will lock text boxes in the main form, but cannot figure out how to lock the subform. Maybe I am type the code wrong when it comes to locking the subform. Any help will be greatly appreciated.
 
What do you mean to lock the subform? You don't want the records in the subform to be modified or don't what anyone to modify and delete records in the subform?

If you set Locked property to Yes, a user still can delete the record.

Tre code below.

Private Sub Check23_AfterUpdate()
Dim ctl As Control
If Me.Check23 = True Then
For Each ctl In Me.Controls
If ctl.ControlType = acSubform Then
'ctl.Locked = True
Me(ctl.Name).Form.AllowAdditions = False
Me(ctl.Name).Form.AllowDeletions = False
Me(ctl.Name).Form.AllowEdits = False
End If
Next
Else
For Each ctl In Me.Controls
If ctl.ControlType = acSubform Then
'ctl.Locked = False
Me(ctl.Name).Form.AllowAdditions = True
Me(ctl.Name).Form.AllowDeletions = True
Me(ctl.Name).Form.AllowEdits = True
End If
Next
End If
End Sub
 

Users who are viewing this thread

Back
Top Bottom