Lock and Unlock subform based on value in main form

  • Thread starter Thread starter Eric Blitzer
  • Start date Start date
E

Eric Blitzer

Windows 2000
Office 2000
Main form - a-schedule-new
Subform1 - A-main-subform
Subform2 - A-main-subform2

I have a form with two subforms in it. Base on if there is
a value in the ApprovedBy field I want to lock or unlock
the subforms. I do not want to lock the main form. Below
is my present code.
Thew error I get when openeing the form is
You entered an expressionthat has an invalid reference to
the propertyForm/Report. The debug brings to this line in
my procedure
[a-schedule-new].[A-main-subform].Form.AllowEdits = False

Can anyone help me accomplish this.


Dim rs As Object

Set rs = Me.Recordset.Clone
rs.FindFirst "[Staff] = '" & Me![Staff] & "'"
Me.Bookmark = rs.Bookmark

If IsNull(Me.ApprovedBy) Then
Me.AllowEdits = True
Me.[A-main-subform].Form.AllowEdits = True
Me.[A-main-subform2].Form.AllowEdits = True
Else
Me.AllowEdits = True
[a-schedule-new].[A-main-subform].Form.AllowEdits = False
[a-schedule-new].[A-main-subform2].Form.AllowEdits = False
End If
 
Eric,

you don't say what event proc you're doing this in

do it in the FORM_CURRENT and it should work

BTW, here is shorthand you may find useful:

[a-schedule-new].[A-main-subform].Form.AllowEdits = not
IsNull(Me.ApprovedBy)
 
Back
Top