User FORM:
I am using the below code to validate that none of the controls on my UserForm are blank when I click on Add to List.
However, I want the cursor to be on the 1st blank textbox. So, ideally in above scenario since all txtbox are blank, the 1st one i.e. Film Name should be the set Focus.
Currently my cursor gets placed on the 3rd Txtbox i.e. "Release date".
I fail to understand the reason behind it. In the Tab Order I have set the order properly as shown in below picture.
What exactly determines the order of CTL in below line of code?
Tab Order Screenshot:
Full Fucntion Code:
I am using the below code to validate that none of the controls on my UserForm are blank when I click on Add to List.
However, I want the cursor to be on the 1st blank textbox. So, ideally in above scenario since all txtbox are blank, the 1st one i.e. Film Name should be the set Focus.
Currently my cursor gets placed on the 3rd Txtbox i.e. "Release date".
I fail to understand the reason behind it. In the Tab Order I have set the order properly as shown in below picture.
What exactly determines the order of CTL in below line of code?
VBA Code:
For Each ctl In Filmframe.Controls
Tab Order Screenshot:
Full Fucntion Code:
Rich (BB code):
Private Function everythingfilledin() As Boolean
Dim ctl As MSForms.Control
Dim anythingmissing As Boolean
everythingfilledin = True
anythingmissing = False
For Each ctl In Filmframe.Controls
If TypeOf ctl Is MSForms.TextBox Or TypeOf ctl Is MSForms.ComboBox Then
If ctl.Value = "" Then
ctl.BackColor = rgbPink
Controls(ctl.Name & "Label").ForeColor = rgbRed
If Not anythingmissing Then ctl.SetFocus
anythingmissing = True
everythingfilledin = False
End If
End If
Next ctl
End Function