One Checkbox checked then checks several

G

Guest

I am trying to write a script and I am new to Outlook coding. I would like to
have a custom form on outlook that has 3 checkbox's and if the first one is
checked, it will then have the other two checked. but if the 2nd or 3rd one
is checked alone it will not check anything else.
 
S

Sue Mosher [MVP-Outlook]

See http://www.outlookcode.com/d/propsyntax.htm. It explains the two types of events -- PropertyChange/CustomPropertyChange and control_Click -- and how to access OUtlook and control properties. If you have questions, post back with more information about your form -- particularly the name of the page, the controls, and the (optional) fields that the controls are bound to.
 
G

Guest

I got the code in and it worked when I hit the run this form from the tools
menu. But when I actually go to use the form once i have exited from the
design mode the code will not work:

Sub Item_CustomPropertyChange(ByVal Name)
If
Item.GetInspector.ModifiedFormPages("Message").Controls("CheckBox3").Value =
True then
Item.GetInspector.ModifiedFormPages("Message").Controls("CheckBox1").Value =
True
Item.GetInspector.ModifiedFormPages("Message").Controls("CheckBox2").Value =
True
Else
End If

End Sub

Any reason that this is happening to me? Is there a solution to this.
 
S

Sue Mosher [MVP-Outlook]

Sounds like you have not yet published the form. Code only runs on published forms.

BTW, if CustomPropertyChange is firing, then you really need to use a Select Case statement to determine *which* property fired and take action only on it. A MsgBox Name statement will show you just how "busy" that event can be.

Also if the checkboxes are bound to Outlook properties, you should be using those property values instead of the control values. It's just more efficient.

--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
G

Guest

I have now published this form in so many locations and have yet to get the
code to work on the form. What am I doing wrong in this case.

I am not really sure how to use a select case in this situation?

With using the properties options. Do I just replace the word controls with
Properties?
 
S

Sue Mosher [MVP-Outlook]

I have now published this form in so many locations and have yet to get the
code to work on the form. What am I doing wrong in this case.

SInce you haven't given us much detail as to what you did, it's impossible to say what you did wrong. Where did you publish the form? What type of form is it (contact, mail, etc.)? What is the state of the "Send form definition with item" check box on the (Properties) page?
I am not really sure how to use a select case in this situation?

Look at the example on the page I suggested and pay attention to the role played by the name of the custom property that changes.

We can help you more if you tell us which of the controls is bound to what property.
With using the properties options. Do I just replace the word controls with
Properties?

I don't understand the question. What does Word have to do with it?
 
G

Guest

With the publishing part. I go to Publish Form and I select Personal Forms or
even Inbox to save it to. It is a mail/message form. I took the message tab
in design and pulled down 3 checkboxes. I went in and assigned them as Yes/No
Type and then assigned them as true/false values and called each box: BOTH,
RESERVE, BLEND, the actual names of the controls were CheckBox1 through 3. I
then went into the VBScript and entered in the code listed below. I then have
the Send Form Definition with item checked as previously instructed by the
outlook dialog box.

I am not sure I follow this statement you wrote: "> We can help you more if
you tell us which of the controls is bound to what property."
 
S

Sue Mosher [MVP-Outlook]

I then have
the Send Form Definition with item checked as previously instructed by the
outlook dialog box.

That's the problem. Code doesn't run on unpublished or one-off forms. Checking that box produces a one-off. Instead, if you want code to run on the recipient's machine, you need to uncheck that box and publish to the Organizational Forms library, if you use Exchange, or to each user's Personal Forms Library.
I am not sure I follow this statement you wrote: "> We can help you more if
you tell us which of the controls is bound to what property."

It means that we can show you how to clean up the code to use UserProperties to access property values directly and write a proper Select Case statement for CustomPropertyChange. The property bound to a control is the one listed at the top of the control's Value tab on the Properties dialog.

--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
G

Guest

So i unchecked the Send Form Definition box. I then tried to publish the form
to the Organizational Forms Library but it wouldnt do to lack of security
permissions. So I loaded it into the personal forms and it still doesnt allow
me to do the code the way I have it intended to do.

So I open up the checkbox's and they are as follows on the value tab:
(CheckBox3) Field Name: BOTH, Type: Yes/No, Format: True/False, Property to
use: Value
(CheckBox2) Field Name: BLEND, Type:Yes/No, Format: True/False, Property to
use: Value
(CheckBox1) Field Name: RESERVE, Type:Yes/No, Format: True/False, Property
to use: Value

I really do appreciate the time you are taking to help me with this.
 
S

Sue Mosher [MVP-Outlook]

Since the check boxes are bound to Outlook user-defined properties, you

a) must use the CustomPropertyChange event to handle the user interaction

b) should work with the property values, not the control values.

Hence:

Sub Item_CustomPropertyChange(ByVal Name)
Select Case Name
Case "BOTH"
If Item.UserProperties("BOTH") = True Then
Item.UserProperties("RESERVE") = True
Item.UserProperties("BLEND") = True
End If
' other Case statements for other properties would go here
End Select
End Sub

See http://www.outlookcode.com/d/propsyntax.htm for more information on these basic techniques.

Note that recipients will not be able to see your custom form unless you publish it to Org Forms or to each user's Personal Forms library. The Exchange Administrator controls the permissions for the Org Forms library.
--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 

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