I have a userform that when initialized each textbox is locked
the form has a commandbutton(edit) to unlock all textboxes
when the user closes the userform if the textboxes are unlocked i want it ask to save any changes.
I am getting a typemismatch on this line
For Each oCtrl In Me.Controls
the whole code is below. does anyone know why?
Private Sub CommandButton1_Click()
Dim oCtrl As MSForms.TextBox
For Each oCtrl In Me.Controls
If oCtrl.Locked = False Then
If MsgBox("You have the form in EDIT MODE, do you want to save any changes?", vbYesNo, Title:="SAVE CHANGES?") = vbYes Then
ElseIf vbNo Then
Unload Me
Set Me = Nothing
End If
ElseIf oCtrl.Locked = True Then
Unload Me
Set Me = Nothing
End If
Next oCtrl
End Sub
Bookmarks