Range question

F

Fuzzhead

If I have a textbox with a number in it and based on that number I want a
check box check. My check boxes are as follows:

Check1 if the number <= 19
Check2 if the number is 20 to 29
Check3 if the number is 30 to 39
Check4 if the number > 40

How do I do Check2 and 3? This is what I have but it does not work.

Dim j As Integer
j = TextBox110.Value
If j <= 19 Then
ActiveDocument.FormFields("Check1").CheckBox.Value = True
ElseIf j >= 20 <= 29 Then
ActiveDocument.FormFields("Check2").CheckBox.Value = True
ElseIf j >= 30 <= 39 Then
ActiveDocument.FormFields("Check3").CheckBox.Value = True
ElseIf j > 40 Then
ActiveDocument.FormFields("Check4").CheckBox.Value = True
End If
 
D

Doug Robbins - Word MVP

Use the following:

With ActiveDocument
If IsNumeric(.FormFields("Text110").result) Then
Select Case Val(.FormFields("Text110").result)
Case Is < 20
.FormFields("Check1").CheckBox.Value = True
.FormFields("Check2").CheckBox.Value = False
.FormFields("Check3").CheckBox.Value = False
.FormFields("Check4").CheckBox.Value = False
Case 20 To 29
.FormFields("Check1").CheckBox.Value = False
.FormFields("Check2").CheckBox.Value = True
.FormFields("Check3").CheckBox.Value = False
.FormFields("Check4").CheckBox.Value = False
Case 30 To 39
.FormFields("Check1").CheckBox.Value = False
.FormFields("Check2").CheckBox.Value = False
.FormFields("Check3").CheckBox.Value = True
.FormFields("Check4").CheckBox.Value = False
Case Is > 40
.FormFields("Check1").CheckBox.Value = False
.FormFields("Check2").CheckBox.Value = False
.FormFields("Check3").CheckBox.Value = False
.FormFields("Check4").CheckBox.Value = True
End Select
Else
MsgBox "You must enter a number."
End If
End With


--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
 
F

Fuzzhead

Thank you again Doug for all your help.



Doug Robbins - Word MVP said:
Use the following:

With ActiveDocument
If IsNumeric(.FormFields("Text110").result) Then
Select Case Val(.FormFields("Text110").result)
Case Is < 20
.FormFields("Check1").CheckBox.Value = True
.FormFields("Check2").CheckBox.Value = False
.FormFields("Check3").CheckBox.Value = False
.FormFields("Check4").CheckBox.Value = False
Case 20 To 29
.FormFields("Check1").CheckBox.Value = False
.FormFields("Check2").CheckBox.Value = True
.FormFields("Check3").CheckBox.Value = False
.FormFields("Check4").CheckBox.Value = False
Case 30 To 39
.FormFields("Check1").CheckBox.Value = False
.FormFields("Check2").CheckBox.Value = False
.FormFields("Check3").CheckBox.Value = True
.FormFields("Check4").CheckBox.Value = False
Case Is > 40
.FormFields("Check1").CheckBox.Value = False
.FormFields("Check2").CheckBox.Value = False
.FormFields("Check3").CheckBox.Value = False
.FormFields("Check4").CheckBox.Value = True
End Select
Else
MsgBox "You must enter a number."
End If
End With


--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top