Selection Fields being both Exclusive and Inclusive

B

bmac

I have written some code where my check boxes can be selected exclusive of
each other. Meaning, when the user click on each check box, the others are
deselected. How can I change my code to where if I want to select only
certain one together, but still allow for the check boxes to be selected
separately? For example, Check A and Check B.....Check A or Check B...Is
there any code that woul
d allow for both instances? Any help would be greatly appreciated. Thanks.

bmac

Sub Vacation()
'
' Vacation Macro
'
ActiveDocument.FormFields("Sick_PaidAb").Result = False
ActiveDocument.FormFields("Breav_PaidAb").Result = False
ActiveDocument.FormFields("FltHol_PaidAb").Result = False
ActiveDocument.FormFields("MilDty_PaidAb").Result = False
ActiveDocument.FormFields("JryDty_PaidAB").Result = False
ActiveDocument.FormFields("UnpaidEx_Ab").Result = False
ActiveDocument.FormFields("FamMed_Leave").Result = False

End Sub

Sub Sick()
'
' Sick Macro
'
ActiveDocument.FormFields("Vac_PaidAb").Result = False
ActiveDocument.FormFields("Breav_PaidAb").Result = False
ActiveDocument.FormFields("FltHol_PaidAb").Result = False
ActiveDocument.FormFields("MilDty_PaidAb").Result = False
ActiveDocument.FormFields("JryDty_PaidAB").Result = False
ActiveDocument.FormFields("UnpaidEx_Ab").Result = False
ActiveDocument.FormFields("FamMed_Leave").Result = False

End Sub

Sub MilitaryDuty()
'
' MilitaryDuty Macro
'
ActiveDocument.FormFields("Vac_PaidAb").Result = False
ActiveDocument.FormFields("Sick_PaidAb").Result = False
ActiveDocument.FormFields("Breav_PaidAb").Result = False
ActiveDocument.FormFields("FltHol_PaidAb").Result = False
ActiveDocument.FormFields("JryDty_PaidAB").Result = False
ActiveDocument.FormFields("UnpaidEx_Ab").Result = False
ActiveDocument.FormFields("FamMed_Leave").Result = False

End Sub
Sub JuryDuty()
'
' JuryDuty Macro
'
ActiveDocument.FormFields("Vac_PaidAb").Result = False
ActiveDocument.FormFields("Sick_PaidAb").Result = False
ActiveDocument.FormFields("Breav_PaidAb").Result = False
ActiveDocument.FormFields("FltHol_PaidAb").Result = False
ActiveDocument.FormFields("MilDty_PaidAb").Result = False
ActiveDocument.FormFields("UnpaidEx_Ab").Result = False
ActiveDocument.FormFields("FamMed_Leave").Result = False

End Sub
Sub Bereavement()
'
' Bereavement Macro
'
ActiveDocument.FormFields("Vac_PaidAb").Result = False
ActiveDocument.FormFields("Sick_PaidAb").Result = False
ActiveDocument.FormFields("FltHol_PaidAb").Result = False
ActiveDocument.FormFields("MilDty_PaidAb").Result = False
ActiveDocument.FormFields("JryDty_PaidAB").Result = False
ActiveDocument.FormFields("UnpaidEx_Ab").Result = False
ActiveDocument.FormFields("FamMed_Leave").Result = False

End Sub
Sub FloatingHoliday()
'
' FloatingHoliday Macro
'
ActiveDocument.FormFields("Vac_PaidAb").Result = False
ActiveDocument.FormFields("Sick_PaidAb").Result = False
ActiveDocument.FormFields("Breav_PaidAb").Result = False
ActiveDocument.FormFields("MilDty_PaidAb").Result = False
ActiveDocument.FormFields("JryDty_PaidAB").Result = False
ActiveDocument.FormFields("UnpaidEx_Ab").Result = False
ActiveDocument.FormFields("FamMed_Leave").Result = False

End Sub
Sub UnpaidExcuseAbsence()
'
' UnpaidExcuseAbsence Macro

ActiveDocument.FormFields("Vac_PaidAb").Result = False
ActiveDocument.FormFields("Sick_PaidAb").Result = False
ActiveDocument.FormFields("Breav_PaidAb").Result = False
ActiveDocument.FormFields("FltHol_PaidAb").Result = False
ActiveDocument.FormFields("MilDty_PaidAb").Result = False
ActiveDocument.FormFields("JryDty_PaidAB").Result = False
ActiveDocument.FormFields("FamMed_Leave").Result = False

End Sub
Sub FamilyMedicalLeave()
'
' FamilyMedicalLeave Macro
'
ActiveDocument.FormFields("Vac_PaidAb").Result = False
ActiveDocument.FormFields("Sick_PaidAb").Result = False
ActiveDocument.FormFields("Breav_PaidAb").Result = False
ActiveDocument.FormFields("FltHol_PaidAb").Result = False
ActiveDocument.FormFields("MilDty_PaidAb").Result = False
ActiveDocument.FormFields("JryDty_PaidAB").Result = False
ActiveDocument.FormFields("UnpaidEx_Ab").Result = False

End Sub
 
C

Charles Kenyon

If you don't have any code, they can be both or either selected. For more
about online forms, follow the links at
http://addbalance.com/word/wordwebresources.htm#Forms or
http://word.mvps.org/FAQs/Customization/FillinTheBlanks.htm especially Dian
Chapman's series of articles. You may also want to look at
http://www.word.mvps.org/FAQs/TblsFldsFms/LinesInForms.htm.

Hope this helps,
--

Charles Kenyon

Word New User FAQ & Web Directory: http://addbalance.com/word

Intermediate User's Guide to Microsoft Word (supplemented version of
Microsoft's Legal Users' Guide) http://addbalance.com/usersguide


--------- --------- --------- --------- --------- ---------
This message is posted to a newsgroup. Please post replies
and questions to the newsgroup so that others can learn
from my ignorance and your wisdom.
 
B

bmac

Thanks Charles for the feedback. You're correct in saying that if there
weren't any code, I could produce the result that I'm looking for. However,
I need to keep the code so that the selections are automatic. Meaning, when
they click on Vac_PaidAb, then click on Sick_PaidAb; the selection will
automatically change from one checkbox to the other without the user having
to deselect the first selection themselves. However, there are times when
they the user need to select two options. For example: If the user click on
Vacation then they will need to be able to click on FMLA...If the user click
on Sick then they will need to be able to click on FMLA....If the user click
 
C

Charles Kenyon

They aren't automatic, in that the user must exit the checkbox field before
your macros are triggered. That is, there is not code for the click event in
the checkbox, unless you are doing something very sophisticated. If it is an
on-exit macro, you could easily have that macro not change other checkboxes
but simply move to the next field you think would ordinarily be appropriate,
allowing the user to come back and check other boxes.

Otherwise you could have your FMLA box enabled / disabled depending on
whether the box is checked. How about some simple written instructions that
tell people when it is appropriate to check more than one box and leave it
to them to properly fill in the form? That is how it works with paper forms.
You could have some code that at some point or other validates whether or
not a combination of checkboxes is appropriate.
http://word.mvps.org/FAQs/TblsFldsFms/ValidateFFields.htm

Otherwise, you could have your on-exit macro check whether the box was
checked and then query the person through an Input Box or UserForm as to
whether FMLA applies and if they say it does, check that box for them. I
believe the advanced articles by Dian Chapman get into such methods. Did you
read them?
--
Charles Kenyon

Word New User FAQ & Web Directory: http://addbalance.com/word

Intermediate User's Guide to Microsoft Word (supplemented version of
Microsoft's Legal Users' Guide) http://addbalance.com/usersguide


--------- --------- --------- --------- --------- ---------
This message is posted to a newsgroup. Please post replies
and questions to the newsgroup so that others can learn
from my ignorance and your wisdom.
 
B

bmac

Hey Charles,
Thanks for the quick response. I added the following code to see if
that would help. I did read the articles but I don't know if I understood
everything they were saying. But, here is the code that I put in. See what
you think.

Sub ExitCheck()

If ActiveDocument.FormFields("Vac_PaidAb").Result Or _
ActiveDocument.FormFields("Sick_PaidAb").Result Or _
ActiveDocument.FormFields("UnpaidEx_Ab").Result Then

ActiveDocument.FormFields("FamMed_Leave").Result = True
Else
ActiveDocument.FormFields("FamMed_Leave").Result = False

End If
End Sub


I thought that the result of this would be if they click vacation, sick, or
unpaid that it would automatically select FamMed otherwise do not select
it...I don't know. What are your thoughts. However, I don't think that this
is what I want to do either. Thanks again for all of your help.

bmac
 
C

Charles Kenyon

Your code does not select the FMLA checkbox, it attempts to check the box.

Does it?

To select the checkbox you would want something like:

ActiveDocument.FormFields("FamMed_Leave").Select
--
Charles Kenyon

Word New User FAQ & Web Directory: http://addbalance.com/word

Intermediate User's Guide to Microsoft Word (supplemented version of
Microsoft's Legal Users' Guide) http://addbalance.com/usersguide


--------- --------- --------- --------- --------- ---------
This message is posted to a newsgroup. Please post replies
and questions to the newsgroup so that others can learn
from my ignorance and your wisdom.
 
B

bmac

Hey Charles,
I see what you mean. I will try select instead, but I guess I was
thinking that the selection process would be up to the user and then the
check will be made. But, again I will try using .select. Thanks Charles. I
will post later to let you know what happens.

bmac
 

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