Mike Krailo
Well-known member
- Local time
- Today, 16:54
- Joined
- Mar 28, 2020
- Messages
- 1,043
I have tried to set some form properties using the code below in on Load, on Open, on Activate. The very first form that loads uses this function and it has no error, but the second form that is called with this function has error runtime 2136 on line 50 "To set this property, open the form or report in Design view." The function works fine when any form is already visibly loaded on the screen. Is there an event that will accommodate this function right after the form loads?
Code:
Function ProtectForm(FrmName As String, Protect As Boolean)
Dim frm As Form
10 Set frm = Forms(FrmName)
20 With frm
30 If Protect = True Then
40 .ShortcutMenu = False
50 .BorderStyle = 3 'Dialog
60 .CloseButton = False
70 .MinMaxButtons = 0 'None
80 Else
90 .ShortcutMenu = True
100 .BorderStyle = 2 'Sizable
110 .CloseButton = True
120 .MinMaxButtons = 3 'Both Enabled
130 End If
140 End With
End Function