vba、outlook、用户窗体(如果是组合框和文本字段)
vba, outlook, Userform if comebox & text fields
我有一个包含 1 个组合框字段和几个文本字段的用户表单。
组合框 1 = 应用程序类型(7 个不同的结果)
姓名、姓氏、城镇、Post 代码等文本字段
按下确定按钮后,如果缺少必填字段,我会提示用户。
必填字段 1 selection 是字段 1、字段 2 和字段 3
对于 selection 2 仅提交 1 和 2 对于 3 仅字段 6
等等
奇怪的是,如果我 select 我没有在此子中定义的东西,我 selecting 值 4 或 5 我仍然收到消息。
我错过了什么?
Private Sub CommandButton1_Click()
If UserForm2.ComboBox1T.Value = "1.New Application" _
And TextBox1.Text = "" _
Or TextBox2.Text = "" _
Or TextBox3.Text = "" _
Then
MsgBox ("Fill in all mandatory Fields")
Exit Sub
End If
If UserForm2.ComboBox1T.Value = "2.Old Application" _
And TextBox1.Text = "" _
Or TextBox2.Text = "" _
Then
MsgBox ("Fill in all mandatory Fields")
Exit Sub
End If
If UserForm2.ComboBox1T.Value = "3.Somethingelse" _
And TextBox1.Text = "" _
Or TextBox2.Text = "" _
Then
MsgBox ("Fill in all mandatory Fields")
Exit Sub
End If
找到解决方案。
With Me
Select Case .ComboBox1T
Case "1.New Application"
If .TB1 = "" Or .TB2 = "" Or .TB3 = "" Then MsgBox ("Something")
Case "2.old Application"
If .TB1 = "" Or .TB2 = "" Then MsgBox ("Something")
Case "3.Other Application"
If ........
Case "4."
Case "5."
Case "6."
Case "7."
End Select
End With
我有一个包含 1 个组合框字段和几个文本字段的用户表单。 组合框 1 = 应用程序类型(7 个不同的结果) 姓名、姓氏、城镇、Post 代码等文本字段
按下确定按钮后,如果缺少必填字段,我会提示用户。
必填字段 1 selection 是字段 1、字段 2 和字段 3 对于 selection 2 仅提交 1 和 2 对于 3 仅字段 6 等等
奇怪的是,如果我 select 我没有在此子中定义的东西,我 selecting 值 4 或 5 我仍然收到消息。 我错过了什么?
Private Sub CommandButton1_Click()
If UserForm2.ComboBox1T.Value = "1.New Application" _
And TextBox1.Text = "" _
Or TextBox2.Text = "" _
Or TextBox3.Text = "" _
Then
MsgBox ("Fill in all mandatory Fields")
Exit Sub
End If
If UserForm2.ComboBox1T.Value = "2.Old Application" _
And TextBox1.Text = "" _
Or TextBox2.Text = "" _
Then
MsgBox ("Fill in all mandatory Fields")
Exit Sub
End If
If UserForm2.ComboBox1T.Value = "3.Somethingelse" _
And TextBox1.Text = "" _
Or TextBox2.Text = "" _
Then
MsgBox ("Fill in all mandatory Fields")
Exit Sub
End If
找到解决方案。
With Me
Select Case .ComboBox1T
Case "1.New Application"
If .TB1 = "" Or .TB2 = "" Or .TB3 = "" Then MsgBox ("Something")
Case "2.old Application"
If .TB1 = "" Or .TB2 = "" Then MsgBox ("Something")
Case "3.Other Application"
If ........
Case "4."
Case "5."
Case "6."
Case "7."
End Select
End With