However, if a subform doesn't have any records, I get Error 2474, "The expression you entered requires the control to be in the active window." The debugger stops on the following line: Screen.ActiveControl.Parent.AllowAdditions = True
Here's the code I'm using:
Expand|Select|Wrap|Line Numbers
- 'Called from clicking a button on the parent form
- Public Function Edit()
- Screen.ActiveForm.AllowEdits = Not Screen.ActiveForm.AllowEdits
- End Function
- 'Called from On Current in the parent form
- Public Function Read()
- Screen.ActiveForm.AllowEdits = False
- End Function
- 'Called from On Enter of the subform control
- Public Function AddEditSub()
- If Screen.ActiveForm.AllowEdits = True Then
- Screen.ActiveControl.Parent.AllowAdditions = True
- Screen.ActiveControl.Parent.AllowEdits = True
- Exit Function
- End If
- End Function
- 'Called from On Enter of the subform control like previous when additions aren't needed
- Public Function EditSub()
- If Screen.ActiveForm.AllowEdits = True Then
- Screen.ActiveControl.Parent.AllowEdits = True
- Exit Function
- End If
- End Function
- 'Called from On Exit of the subform control
- Public Function ReadSub()
- Screen.ActiveControl.Parent.AllowAdditions = False
- Screen.ActiveControl.Parent.AllowEdits = False
- End Function
Thanks,
Frieda