Populating the to field based on values of multiple check boxes on the outlook form

J

jay.tabatabai

Hello to all outlook form experts out there;

I am a total newbie to Outlook forms programming and have been
challenged with creating a form with 3 checkboxes ( LA , LV and CH )
to be able to construct the "To" field. For instance, if all three
are checked, the "To" field would be "LA; LV; CH". This
functionality will need to work for all permutations of checkbox
selection possibilities.



Various Permutations:

LA Checkbox = True
LV Checkbox = True
CH Checkbox = True

Then the value in To field will be (e-mail address removed); (e-mail address removed);
(e-mail address removed)

If
LA Checkbox = True
LV Checkbox = True
CH Checkbox = False

Then the value in To field will be (e-mail address removed); (e-mail address removed)

& .............

Are there any code examples for creating a form similar to what I have
been tasked with.

I will appreciate any guidance and/or advice that can put me on the
right track.
 
J

jay.tabatabai

The details will depend on whether you're using bound or unbound controls; seehttp://www.outlookcode.com/article.aspx?ID=38for basic syntax for both.

--
Sue Mosher, Outlook MVP
Author of Microsoft Outlook 2007 Programming:
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54














- Show quoted text -

Thanks for your reply,
I looked at the reference material but for some reason , added it to
the form's script editor but could not make the click event respond
Item_PropertyChange(ByVal Name) , and not sure what I was doing wrong.

However I managed to make the form work using the code below.
---------------------------------
LA = 0
LV = 0
CH = 0

Sub CheckBox_LA_Click()
If LA = 0 Then
LA = 1
Else
LA = 0
End If

To_Text = ""
If LA = 1 Then
To_Text = "(e-mail address removed)"
End If

If LV = 1 Then
If To_Text <> "" Then
To_Text = To_Text & ";[email protected]"
Else
To_Text = "(e-mail address removed)"
End If
End If

If CH = 1 Then
If To_Text <> "" Then
To_Text = To_Text & ";[email protected]"
Else
To_Text = "(e-mail address removed)"
End If
End If

Item.To = To_Text
End Sub

Sub CheckBox_LV_Click()
If LV = 0 Then
LV = 1
Else
LV = 0
End If

To_Text = ""
If LA = 1 Then
To_Text = "(e-mail address removed)"
End If

If LV = 1 Then
If To_Text <> "" Then
To_Text = To_Text & ";[email protected]"
Else
To_Text = "(e-mail address removed)"
End If
End If

If CH = 1 Then
If To_Text <> "" Then
To_Text = To_Text & ";[email protected]"
Else
To_Text = "(e-mail address removed)"
End If
End If

Item.To = To_Text
End Sub

Sub CheckBox_CH_Click()
If CH = 0 Then
CH = 1
Else
CH = 0
End If

To_Text = ""
If LA = 1 Then
To_Text = "(e-mail address removed)"
End If

If LV = 1 Then
If To_Text <> "" Then
To_Text = To_Text & ";[email protected]"
Else
To_Text = "(e-mail address removed)"
End If
End If

If CH = 1 Then
If To_Text <> "" Then
To_Text = To_Text & ";[email protected]"
Else
To_Text = "(e-mail address removed)"
End If
End If

Item.To = To_Text
End Sub
 
S

Sue Mosher [MVP-Outlook]

You didn't say whether you are working with bound or unbound controls. As the article I suggested explains, that determines which events are available. The fact that you got a Click event to work indicates that the check box is unbound. FYI, for your logic, it would be better to use True and False instead of 1 and 0.
 

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