PDA

View Full Version : Word 03 Checkbox Problem



oglezsa
04-01-2010, 09:32 AM
Hello,
I been looking for an answer that it think is easy but no luck....I have 9 checkboxes,(Checkbox1, checkbox2,...,checkbox9) and at the beginig when the userform starts Checkbox9 is active and selected. That works fine, the other part is when one of the other 8 (Checkbox1 through 8) is selected Checkbox9 will dim, that also works fine, but here is my problem... when ALL of the other 8 are unchecked, checkbox 9 remains dim not letting the user select Checkbox9 and what I need is to be active again when all the others are unchecked.I hope someone has the solution since im a newbie in VBA.

I appreciate your help

lucas
04-01-2010, 09:37 AM
Can you sanitize your document and post it with the userform so we don't have to duplicate what you have in your hands?

click on go advanced and scroll down till you see the button that says manage attachments.

oglezsa
04-01-2010, 09:55 AM
Option Explicit

'Private Sub CommandButton5_Click()
'Dim cCont As Control

'For Each cCont In Me.Controls
'If TypeName(cCont) = "CheckBox" Then
'cCont.Value = False
'End If
'Next cCont
'CheckBox9.Value = True
'CheckBox9.Enabled = True
'CheckBox10.Value = True

End Sub
Private Sub UserForm_Initialize()
CheckBox10.Value = True
CheckBox9.Value = True
TextBox23.Enabled = False
TextBox24.Enabled = False
TextBox25.Enabled = False
TextBox26.Enabled = False
TextBox27.Enabled = False
TextBox28.Enabled = False

With ComboBox1
.AddItem "Life"
.AddItem "Health"
.AddItem "Disability"
.AddItem "Critical Illness"

End With
End Sub
Private Sub CheckBox1_Click()
If CheckBox1.Value = True Then
CheckBox9.Value = False
CheckBox9.Enabled = False
TextBox23.Enabled = True
Else
TextBox23.Enabled = False
End If
End Sub
Private Sub CheckBox2_Click()
If CheckBox2.Value = True Then
CheckBox9.Value = False
CheckBox9.Enabled = False
TextBox24.Enabled = True
Else
TextBox24.Enabled = False
End If
End Sub
Private Sub CheckBox3_Click()
If CheckBox3.Value = True Then
CheckBox9.Value = False
CheckBox9.Enabled = False
TextBox25.Enabled = True
Else
TextBox25.Enabled = False
End If
End Sub
Private Sub CheckBox4_Click()
If CheckBox4.Value = True Then
CheckBox9.Value = False
CheckBox9.Enabled = False
TextBox26.Enabled = True
Else
TextBox26.Enabled = False
End If
End Sub
Private Sub CheckBox5_Click()
If CheckBox5.Value = True Then
CheckBox9.Value = False
CheckBox9.Enabled = False
End If
End Sub
Private Sub CheckBox6_Click()
If CheckBox6.Value = True Then
CheckBox9.Value = False
CheckBox9.Enabled = False
End If
End Sub
Private Sub CheckBox7_Click()
If CheckBox7.Value = True Then
CheckBox9.Value = False
CheckBox9.Enabled = False
TextBox27.Enabled = True
Else
TextBox27.Enabled = False
End If
End Sub
Private Sub CheckBox8_Click()
If CheckBox8.Value = True Then
CheckBox9.Value = False
CheckBox9.Enabled = False
TextBox28.Enabled = True
Else
TextBox28.Enabled = False
End If
End Sub

Private Sub CommandButton1_Click()
Dim strTypevar As String
Dim strTypevar1 As String
Dim strTypevar2 As String
Dim strTypevar3 As String
Dim strTypevar4 As String
Dim strTypevar5 As String
Dim strTypevar6 As String
Dim strTypevar7 As String
Dim strTypevar8 As String
Dim strTypevar9 As String
Dim strTypevar10 As String
Dim strTypevar11 As String
Dim strTypevar12 As String
Dim strTypevar13 As String

With ActiveDocument
.Bookmarks("DATE").Range _
.InsertBefore TextBox22
.Bookmarks("CEOFNM").Range _
.InsertBefore TextBox1
.Bookmarks("CEOMDI").Range _
.InsertBefore TextBox16
.Bookmarks("CEOLNM").Range _
.InsertBefore TextBox2
.Bookmarks("CEONMS").Range _
.InsertBefore TextBox3
.Bookmarks("CEPOLN").Range _
.InsertBefore TextBox11
.Bookmarks("CEPPPD").Range _
.InsertBefore ComboBox1

End With

If CheckBox9.Value = True Then
Selection.GoTo What:=wdGoToBookmark, Name:="START"
Selection.EndKey Unit:=wdLine, Extend:=wdExtend
Selection.Delete Unit:=wdCharacter, Count:=1
End If


If CheckBox8.Value = True Then
TextBox28.Enabled = True
CheckBox9.Value = False
CheckBox9.Enabled = False
With ActiveDocument
Selection.GoTo What:=wdGoToBookmark, Name:="START"
Selection.TypeParagraph
With ActiveDocument.Bookmarks
.Add Range:=Selection.Range, Name:="OTHER"
.DefaultSorting = wdSortByName
.ShowHidden = False
End With
Selection.TypeText Text:=" "
With ActiveDocument.Bookmarks
.Add Range:=Selection.Range, Name:="OTHER1"
.DefaultSorting = wdSortByName
.ShowHidden = False
End With
End With

With ActiveDocument
strTypevar8 = "Other: "
.Bookmarks("OTHER").Range _
.InsertBefore strTypevar8
.Bookmarks("OTHER1").Range _
.InsertBefore TextBox28
End With
End If

If CheckBox7.Value = True Then
TextBox27.Enabled = True
CheckBox9.Value = False
CheckBox9.Enabled = False
With ActiveDocument
Selection.GoTo What:=wdGoToBookmark, Name:="START"
Selection.TypeParagraph
With ActiveDocument.Bookmarks
.Add Range:=Selection.Range, Name:="ACDBEN"
.DefaultSorting = wdSortByName
.ShowHidden = False
End With
Selection.TypeText Text:=" "
With ActiveDocument.Bookmarks
.Add Range:=Selection.Range, Name:="ACDBEN1"
.DefaultSorting = wdSortByName
.ShowHidden = False
End With
End With


With ActiveDocument
strTypevar7 = "Accidental Death and Dismemberment Benefit Amount adjusted to $"
.Bookmarks("ACDBEN").Range _
.InsertBefore strTypevar7
.Bookmarks("ACDBEN1").Range _
.InsertBefore TextBox27
End With
End If

If CheckBox6.Value = True Then
CheckBox9.Value = False
CheckBox9.Enabled = False
With ActiveDocument
Selection.GoTo What:=wdGoToBookmark, Name:="START"
Selection.TypeParagraph
With ActiveDocument.Bookmarks
.Add Range:=Selection.Range, Name:="WAPRAI"
.DefaultSorting = wdSortByName
.ShowHidden = False
End With
End With


With ActiveDocument
strTypevar6 = "Waiver of Premium Rider deleted. "
.Bookmarks("WAPRAI").Range _
.InsertBefore strTypevar6
End With
End If

If CheckBox5.Value = True Then
CheckBox9.Value = False
CheckBox9.Enabled = False
With ActiveDocument
Selection.GoTo What:=wdGoToBookmark, Name:="START"
Selection.TypeParagraph
With ActiveDocument.Bookmarks
.Add Range:=Selection.Range, Name:="WAPBEN"
.DefaultSorting = wdSortByName
.ShowHidden = False
End With
End With

With ActiveDocument
strTypevar5 = "Waiver of Premium Benefit deleted. "
.Bookmarks("WAPBEN").Range _
.InsertBefore strTypevar5
End With
End If

If CheckBox4.Value = True Then
TextBox26.Enabled = True
CheckBox9.Value = False
CheckBox9.Enabled = False
With ActiveDocument
Selection.GoTo What:=wdGoToBookmark, Name:="START"
Selection.TypeParagraph
With ActiveDocument.Bookmarks
.Add Range:=Selection.Range, Name:="FAMCH"
.DefaultSorting = wdSortByName
.ShowHidden = False
End With
Selection.TypeText Text:=" "
With ActiveDocument.Bookmarks
.Add Range:=Selection.Range, Name:="FAMCH1"
.DefaultSorting = wdSortByName
.ShowHidden = False
End With
Selection.TypeText Text:=" "

strTypevar4 = "Face Amount changed to $"
.Bookmarks("FAMCH").Range _
.InsertBefore strTypevar4
.Bookmarks("FAMCH1").Range _
.InsertBefore TextBox26
End With
End If

If CheckBox3.Value = True Then
TextBox25.Enabled = True
CheckBox9.Value = False
CheckBox9.Enabled = False
Selection.GoTo What:=wdGoToBookmark, Name:="START"
Selection.TypeParagraph
With ActiveDocument.Bookmarks
.Add Range:=Selection.Range, Name:="DPOLCH"
.DefaultSorting = wdSortByName
.ShowHidden = False
End With
Selection.TypeText Text:=" "
With ActiveDocument.Bookmarks
.Add Range:=Selection.Range, Name:="DPOLCH1"
.DefaultSorting = wdSortByName
.ShowHidden = False
End With
With ActiveDocument
strTypevar3 = "Date of Policy changed to "
.Bookmarks("DPOLCH").Range _
.InsertBefore strTypevar3
.Bookmarks("DPOLCH1").Range _
.InsertBefore TextBox25
End With
End If

If CheckBox2.Value = True Then
TextBox24.Enabled = True
CheckBox9.Value = False
CheckBox9.Enabled = False
Selection.GoTo What:=wdGoToBookmark, Name:="START"
Selection.TypeParagraph
With ActiveDocument.Bookmarks
.Add Range:=Selection.Range, Name:="MODAL"
.DefaultSorting = wdSortByName
.ShowHidden = False
End With
Selection.TypeText Text:=" "
With ActiveDocument.Bookmarks
.Add Range:=Selection.Range, Name:="MODAL1"
.DefaultSorting = wdSortByName
.ShowHidden = False
End With
With ActiveDocument
strTypevar2 = "Modal Premium changed to $"
.Bookmarks("MODAL").Range _
.InsertBefore strTypevar2
.Bookmarks("MODAL1").Range _
.InsertBefore TextBox24
End With

End If

If CheckBox1.Value = True Then
TextBox23.Enabled = True
CheckBox9.Value = False
CheckBox9.Enabled = False
Selection.GoTo What:=wdGoToBookmark, Name:="START"
Selection.TypeParagraph
With ActiveDocument.Bookmarks
.Add Range:=Selection.Range, Name:="ANPREAD"
.DefaultSorting = wdSortByName
.ShowHidden = False
End With
Selection.TypeText Text:=" "
With ActiveDocument.Bookmarks
.Add Range:=Selection.Range, Name:="ANPREAD1"
.DefaultSorting = wdSortByName
.ShowHidden = False
End With
Selection.TypeText Text:=" "
With ActiveDocument.Bookmarks
.Add Range:=Selection.Range, Name:="ANPREAD2"
.DefaultSorting = wdSortByName
.ShowHidden = False
End With
With ActiveDocument
strTypevar = "Annual Premium amount adjusted to $"
.Bookmarks("ANPREAD").Range _
.InsertAfter strTypevar
.Bookmarks("ANPREAD1").Range _
.InsertAfter TextBox23
End With
End If

If CheckBox1.Value = True Then
With ActiveDocument
strTypevar1 = " . (Your Premium may change later, see Policy for additional information.)" _
& vbCrLf & "Any future policy issued in exercise of any conversion right will be on the same rate" _
& vbCrLf & "classification as this Policy."
.Bookmarks("ANPREAD2").Range _
.InsertAfter strTypevar1
End With
End If


If CheckBox10.Value = False Then
Selection.GoTo What:=wdGoToBookmark, Name:="SIGNATURE"
Selection.MoveRight Unit:=wdCharacter, Count:=2, Extend:=wdExtend
Selection.MoveDown Unit:=wdLine, Count:=15, Extend:=wdExtend
Selection.Delete Unit:=wdCharacter, Count:=1
End If

UserForm1.Hide
End Sub

Private Sub CommandButton3_Click()
'This will cancel and close the form
Unload Me
ActiveDocument.Close SaveChanges:=False
End Sub

Private Sub CommandButton4_Click()
'This will reset the form with out closing it
Unload Me
UserForm1.Show

End Sub


Edit Lucas: VBA tags added to code. You can format your code for the forum by selecting it when posting and hitting the vba button.

lucas
04-01-2010, 10:04 AM
So you still want me to create a userform and figure out what's on it?

attachment. Attach your document.

You obviously work for an insurance company so I know you expect people to read the details.....

oglezsa
04-01-2010, 10:09 AM
Sorry, my firewall does not allow me to attach any document, what i can do is send it to you via e-mail. So if you give me an address i can send it to you.

lucas
04-01-2010, 10:20 AM
Well, you don't allow pm's in your profile and I don't want to post my email in public. send me a pm with your email address.

oglezsa
04-01-2010, 10:31 AM
How do i do that?..im new in this Forum

lucas
04-01-2010, 10:34 AM
click on lucas on the left side of my posts and a drop down will show. select send private message to lucas.

oglezsa
04-01-2010, 10:40 AM
Here is what i get...

oglezsa, you do not have permission to access this page. This could be due to one of several reasons:

Your user account may not have sufficient privileges to access this page. Are you trying to edit someone else's post, access administrative features or some other privileged system?
If you are trying to post, the administrator may have disabled your account, or it may be awaiting activation.

lucas
04-01-2010, 10:43 AM
then edit your profile to allow pm's

lucas
04-01-2010, 11:08 AM
I sent you an email

lucas
04-01-2010, 11:39 AM
There was no userform in the letter.dot that you emailed to me.

fumei
04-01-2010, 11:46 AM
Without the userform itself to look at, I think/b] this is what you are saying:

"That works fine, the other part is when one of the other 8 (Checkbox1 through 8) is selected Checkbox9 will dim, that also works fine, but here is my problem... when ALL of the other 8 are unchecked, checkbox 9 remains dim not letting the user select Checkbox9"

So, Checkbox9 is fine, but IF other checkbox are checked, Checkbox9 is disabled - and this is apparently OK - but IF the other checkbox are [b]unselected, Checkbox remains disabled, and you want it enabled IF all (but ONLY if all) other checkboxes are False (unchecked).

Correct?

In other words:

ALL other checkbox = False, Then Checkbox9 = enabled
ANY other checkbox = True, Then Checkbox9 = DISabled

oglezsa
04-01-2010, 02:16 PM
yes, that is exactly what im trying to do

oglezsa
04-06-2010, 07:08 AM
I finally got it work the way they want, I appreciate everyones help on this.

oglezsa
04-06-2010, 07:12 AM
Thanks!