All right. I thought I was gettin somewhere. Thank you mikerickson for the suggestion. Using Type(Ctrl) vba gives me a compile error expected: expression so I changed it to TypeName(Ctrl) and the compile error resolved. However, even though I ran the below code and worked as intended (even following the tab order!):
For Each Ctrl In Controls
If TypeName(Ctrl) = "Textbox" Then
Select Case TypeName(Ctrl.Parent)
Case "Page"
If Ctrl.Value = "" Then
Ctrl.BackColor = vbYellow
Ctrl.Parent.Parent.Value = Ctrl.Parent.Index
Ctrl.SetFocus
MsgBox Ctrl.Name & " is required.", vbOKOnly, "Missing Item"
Exit Sub
End If
Case Else
If Ctrl.Value = "" Then
Ctrl.BackColor = vbYellow
MsgBox Ctrl.Name & " is required.", vbOKOnly, "Missing Item"
Ctrl.SetFocus
Exit Sub
End If
End Select
End If
Next Ctrl
It errored (now 2110) on the Ctrl.SetFocus because there are also comboboxes on the form as well (I know just enough that obviously it's going to error due to the typename constraint). I do have a branch of code to deal with empty comboboxes. Even more odd to me, after that error, now when I run the code , the code no longer executes. It bypasses and goes straight to my msgbox. I shut down the application and it still no longer executes the code. I feel like I'm falling deeper into the rabbit hole on this
Bookmarks