JC501
12-12-2010, 03:02 AM
Hi, I have a Userform with 3 check boxes, 2 text boxes and 3 combo boxes.
When check box 3 is checked I want to ensure that combobox 1 is actioned.
Text box 1 is also mandatory but not text box 2.
Combo box 2 is not mandatory. Combo box 3 is.
I have used message boxes to try to prompt people to fill in but they just ignore them!!
VBA
Private Sub CommandButton1_Click()
Selection.GoTo What:=wdGoToBookmark, Name:="Manager"
If CheckBox1.Value = True Then
Selection.TypeText Text:="Yes"
Else
Selection.TypeText Text:=""
End If
Selection.GoTo What:=wdGoToBookmark, Name:="Depthead"
If CheckBox2.Value = True Then
Selection.TypeText Text:="Yes"
Else
Selection.TypeText Text:=""
End If
Selection.GoTo What:=wdGoToBookmark, Name:="AuthSig"
If CheckBox3.Value = True Then
Selection.TypeText Text:="Yes"
Else
Selection.TypeText Text:=""
End If
Application.ScreenUpdating = True
Selection.GoTo What:=wdGoToBookmark, Name:="Location1"
Selection.Text = UserForm4.TextBox1.Text
Selection.GoTo What:=wdGoToBookmark, Name:="Dept"
Selection.Text = UserForm4.TextBox2.Text
With ActiveDocument
.Bookmarks("Authsigtype").Range.Text = ComboBox1.Value
.Bookmarks("Floor").Range.Text = ComboBox2.Value
.Bookmarks("Service").Range.Text = ComboBox3.Value
End With
Unload UserForm4
End Sub
Private Sub CommandButton2_Click()
End
End Sub
Private Sub UserForm_Click()
End Sub
Private Sub UserForm_Initialize()
With ComboBox1
.AddItem "Up to £1,000"
.AddItem "Up to £5,000"
.AddItem "Up to £10,000"
.AddItem "Up to £20,000"
End With
With ComboBox2
.AddItem "Basement"
.AddItem "Ground"
.AddItem "1st Floor"
.AddItem "2nd Floor"
.AddItem "3rd Floor"
.AddItem "4th Floor"
End With
With ComboBox3
.AddItem "Helpdesk"
.AddItem "Information"
.AddItem "Contact Centre"
.AddItem "Lending"
.AddItem "Insurance"
.AddItem "Arrears"
End With
End Sub
When check box 3 is checked I want to ensure that combobox 1 is actioned.
Text box 1 is also mandatory but not text box 2.
Combo box 2 is not mandatory. Combo box 3 is.
I have used message boxes to try to prompt people to fill in but they just ignore them!!
VBA
Private Sub CommandButton1_Click()
Selection.GoTo What:=wdGoToBookmark, Name:="Manager"
If CheckBox1.Value = True Then
Selection.TypeText Text:="Yes"
Else
Selection.TypeText Text:=""
End If
Selection.GoTo What:=wdGoToBookmark, Name:="Depthead"
If CheckBox2.Value = True Then
Selection.TypeText Text:="Yes"
Else
Selection.TypeText Text:=""
End If
Selection.GoTo What:=wdGoToBookmark, Name:="AuthSig"
If CheckBox3.Value = True Then
Selection.TypeText Text:="Yes"
Else
Selection.TypeText Text:=""
End If
Application.ScreenUpdating = True
Selection.GoTo What:=wdGoToBookmark, Name:="Location1"
Selection.Text = UserForm4.TextBox1.Text
Selection.GoTo What:=wdGoToBookmark, Name:="Dept"
Selection.Text = UserForm4.TextBox2.Text
With ActiveDocument
.Bookmarks("Authsigtype").Range.Text = ComboBox1.Value
.Bookmarks("Floor").Range.Text = ComboBox2.Value
.Bookmarks("Service").Range.Text = ComboBox3.Value
End With
Unload UserForm4
End Sub
Private Sub CommandButton2_Click()
End
End Sub
Private Sub UserForm_Click()
End Sub
Private Sub UserForm_Initialize()
With ComboBox1
.AddItem "Up to £1,000"
.AddItem "Up to £5,000"
.AddItem "Up to £10,000"
.AddItem "Up to £20,000"
End With
With ComboBox2
.AddItem "Basement"
.AddItem "Ground"
.AddItem "1st Floor"
.AddItem "2nd Floor"
.AddItem "3rd Floor"
.AddItem "4th Floor"
End With
With ComboBox3
.AddItem "Helpdesk"
.AddItem "Information"
.AddItem "Contact Centre"
.AddItem "Lending"
.AddItem "Insurance"
.AddItem "Arrears"
End With
End Sub