2017-05-24 25 views
0

我有用户窗体,有1个组合框和几个文本框。 组合框1 =类型的应用程序(7个不同的结果),如名字,姓氏,城镇,邮编等 文本字段vba,outlook,用户表单,如果comebox和文本字段

按下确定按钮后,我想提示用户如果强制字段丢失。

1个选择必填字段为字段1,字段2和字段3 只有3场只申请1和2选择2 6 等

奇怪的是,如果我选择的东西我没有定义在这一部分,我选择了价值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 
+0

啊,我知道你错过了什么。你错过了[this](https://meta.stackexchange.com/questions/5234/how-does-accepting-an-answer-work/5235#5235),因为那些花费宝贵时间回答你的问题的人。 – Tehscript

+0

我的错误,全部排序。我刚开始用stackoverflow,并不知道如何一切正常。 – folkstorm

回答

0

找到解决办法。

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 
相关问题