J
jtb3
Good morning, Reading this discussion group's threads made me aware of Allen
Browne's very informative website. I have tried to implement his program for
locking bound controls on a test form and subform
(http://allenbrowne.com/ser-56.html). I have created a tblTest with a PK
composed of an AutoNumber and a TestID; there is also a field [Vendor] in the
table. I then created a table for the subform with a FK = TestID (linked to
PK Master/Child and whose "Visible" attribute = False) and a field for
[Group]. All of these fields are formatted as text with the exception of the
AutoNumber field. The mainform, formTest, contains a bound text box [TestID],
a bound combo box [Vendor], and a command button 'Lock/Unlock'. I then
inserted a TabCtrl on the form to add the subform. Mr Browne's program works
well to this point. As soon as I add a subform (with a bound text box
[TestID] and a bound combo box [Group]) the program gives the error 2465 -
Application-defined or Object-defined error and the command button does not
change but remains fixed in the 'Lock' mode with the red rectangle
(indicating a locked record) visible. Originally if the red rectangle was
visible, the command button showed "Unlock" which allowed access for
edits/data entry. The line of code that gives the error is in this Function
(abbreviated to save space):
Public Function LockBoundControls(frm As Form, bLock As Boolean, ParamArray
avarExceptionList())
On Error GoTo Err_Handler
'Purpose: Lock the bound controls and prevent deletes on the form any
its subforms.
'Arguments frm = the form to be locked
' bLock = True to lock, False to unlock.
' avarExceptionList: Names of the controls NOT to lock
(variant array of strings).
'Usage: Call LockBoundControls(Me. True)
Dim ctl As Control 'Each control on the form
Dim lngI As Long 'Loop controller.
Dim bSkip As Boolean
Browne's very informative website. I have tried to implement his program for
locking bound controls on a test form and subform
(http://allenbrowne.com/ser-56.html). I have created a tblTest with a PK
composed of an AutoNumber and a TestID; there is also a field [Vendor] in the
table. I then created a table for the subform with a FK = TestID (linked to
PK Master/Child and whose "Visible" attribute = False) and a field for
[Group]. All of these fields are formatted as text with the exception of the
AutoNumber field. The mainform, formTest, contains a bound text box [TestID],
a bound combo box [Vendor], and a command button 'Lock/Unlock'. I then
inserted a TabCtrl on the form to add the subform. Mr Browne's program works
well to this point. As soon as I add a subform (with a bound text box
[TestID] and a bound combo box [Group]) the program gives the error 2465 -
Application-defined or Object-defined error and the command button does not
change but remains fixed in the 'Lock' mode with the red rectangle
(indicating a locked record) visible. Originally if the red rectangle was
visible, the command button showed "Unlock" which allowed access for
edits/data entry. The line of code that gives the error is in this Function
(abbreviated to save space):
Public Function LockBoundControls(frm As Form, bLock As Boolean, ParamArray
avarExceptionList())
On Error GoTo Err_Handler
'Purpose: Lock the bound controls and prevent deletes on the form any
its subforms.
'Arguments frm = the form to be locked
' bLock = True to lock, False to unlock.
' avarExceptionList: Names of the controls NOT to lock
(variant array of strings).
'Usage: Call LockBoundControls(Me. True)
Dim ctl As Control 'Each control on the form
Dim lngI As Long 'Loop controller.
Dim bSkip As Boolean