making frames dissapear using checkboxes

D

daphnejean77

I have a code to cause frames to disapear/reappear when a checkbox is marked
or unmarked. I am using this code for a custom email form I am designing.
The frames are successfully staying hidden and reappearing when asked to,
however once I send the email, all frames are visible to the receiver. How
can I modify this code or the frames to make the correct frames stay hidden.
Here is the code I have been using:

Sub CheckBox3_Click()
Set myinspector = Item.GetInspector
Set myPage1 = myInspector.ModifiedFormPages("Message")
Set frame2 = myPage1.Controls("frame2")
Set Checkbox3 = myPage1.Controls("CheckBox3")
frame2.Visible = Checkbox3.Value
End Sub

Thank you,
Daphne
 
S

Sue Mosher [MVP-Outlook]

Run similar code in the Item_Open event handler. You'll also need to change the design and add a yes/no property that can store the information that the frame should be visible or not visible.

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
D

daphnejean77

I am sorry, but I am still getting used to some of the functions and fields.
I am confused about what you are saying below. I don't even know where to
begin for either suggestion. Can you help?
 
S

Sue Mosher [MVP-Outlook]

What specifically don't you understand? We've already covered the yes/no property in your other thread.

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
D

daphnejean77

How do I design a frame to have a Yes/No property? Also when you refer to
running a similar code in the Item_Open event handler, I should be writing a
code that hides the appropriate frames once the email is opened? I am sorry
if I seem to be slow at this. I have been struggling through the creation of
multiple forms with and without scripting for the past three weeks and it
seems to be jumbling together at this moment. If you could offer som advice
hopefully it will unjumble my head.
thank you again
 
S

Sue Mosher [MVP-Outlook]

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers


daphnejean77 said:
How do I design a frame to have a Yes/No property?

A frame cannot have a yes/no property. What you need is a yes/no property to store information about the state of the frame (visible/hidden).
Also when you refer to
running a similar code in the Item_Open event handler, I should be writing a
code that hides the appropriate frames once the email is opened?

Right. That's what you want, isn't it?
If you could offer som advice hopefully it will unjumble my head.

The best advice I can offer is not to try to do everything at once. You may even want to step away from the keyboard and sketch out your form's needs with pencil and paper. Make a note of what information the form might need to store in an individual item so that the person who opens that item will see what you want them to see. Remember that Outlook does not persist the look of a form between sessions. When the user opens the item, Outlook starts with whatever the published form looks like.
 
D

daphnejean77

Thank you for your help you have been truelly wonderful in all of this. I am
still having trouble, but it gets clearer from time to time. I do not know
where I am going wrong today or why these codes are not working but I have
two codes that are holding up the entirety of my forms. I have written the
below code so far for the Item_Open event. Believe it or not though, I am not
understanding how to create a Yes/No Property that will store information
about the frame.

Sub Item_Open
If CheckBox4 = ?????
Set myinspector = Item.GetInspector
Set myPage1 = myInspector.ModifiedFormPages("Message")
Set frame4 = myPage1.Controls("frame4")
Set Checkbox5 = myPage1.Controls("CheckBox5")
frame4.Visible = Checkbox5.Value
End Sub

How do I make this code work?

How do I set the Yes/No property? Does the check box do that? How do I
link them together? I guess I don't understand this component of everything.
 
S

Sue Mosher [MVP-Outlook]

I am not understanding how to create a Yes/No Property that will store information about the frame.

Let's try breaking this down into two concepts. I think may help you put it together.

You know how to create a yes/no property, right? Just click the New button on the Field Chooser, choose the type of property and give it a name. You might call it FrameVisible to remind you of what the property means. (If you already have a property you're using, that's fine, too. We can go with that. I think it might be helpful, though, for you to think of even an existing yes/no property as the "FrameVisible" property.)

Now you have a place to store information about the state of the frame. So far so good? The next question is: How does the property become associated with the frame's visibility? In two ways -- the user needs a way to interact with the property, and the form needs code that use the property value to change the Visibility property of the frame. You can take care of the first with a check box. Drag the property from the Field Chooser to the form, and Outlook will create a check box automatically. For the second, you need to write code in two places -- the CustomPropertyChange event and the Open event. More on that in our next installment. For now, I just want to make sure you have the "big picture," with diagrammed out, looks something like this:

User > check box > property

Property > code > frame visibility

In other words, the user interacts with the check box to change the property value, and the code uses the property value to alter the frame's visibility.

With me so far?

BTW, you said this is a custom email form. Is it for internal use only? Do you have permission to publish forms to the Organizational Forms library on your Exchange Server?

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
D

daphnejean77

Ok, so I actually understood more than I thought I did. I have a checkbox
already created with the property to tie it to the frame. Now I am really
struggling with writing code for Custom Property Change and the Open event.
I don't have permission to publish them to the exchange server, but once the
forms are created they will be published by IT to the exchange server. For
the moment I publish them to my personal forms to make sure they work
properly.
I have been going over and over the link for writing CustomPropertyChange
code and it is where I seem to be getting stuck for some reason.
 
S

Sue Mosher [MVP-Outlook]

Why don't you show us what you have and give us an idea of where you're stuck?

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
D

daphnejean77

I am trying to start over this morning I am still having trouble writing
the Code for the CustomPropertyChange I don't know what I am missing. Can
you maybe give me an example code to start with - I haven't been able to
piece together the right pieces and I can't seem to find anything to compare
the code to.
 
D

daphnejean77

So far I have the below code, it is giving me an error on line three and I am
not even sure I am headed in the right direction at this point.

Sub Item_CustomPropertyChange(ByVal Name)
Select Case Name
Case “ITTicketVisibleâ€
strFrame4 = Item.UserProperties(“ITTicketVisibleâ€)
Select Case strITTicketVisible
If “ITTicketVisible†= ????WHAT????
Set myinspector = Item.GetInspector
Set myPage1 = myInspector.ModifiedFormPages("Message")
Set frame4 = myPage1.Controls("Frame4")
Set ITTicketVisible = myPage1.Controls("ITTicketVisible")
Frame4.Visible = ITTicketVisible.Value
End Select
End Sub
 
S

Sue Mosher [MVP-Outlook]

You're definitely headed in the right direction. I don't know if you see it laid out differently in your code window but indenting is your friend and can show you possible problem areas, so let's give your code some proper indenting to see what clues that might give us:

Sub Item_CustomPropertyChange(ByVal Name)
Select Case Name
Case “ITTicketVisibleâ€
strFrame4 = Item.UserProperties(“ITTicketVisibleâ€)
Select Case strITTicketVisible
If “ITTicketVisible†= ????WHAT????
Set myinspector = Item.GetInspector
Set myPage1 = myInspector.ModifiedFormPages("Message")
Set frame4 = myPage1.Controls("Frame4")
Set ITTicketVisible = myPage1.Controls("ITTicketVisible")
Frame4.Visible = ITTicketVisible.Value
End Select
End Sub

It should be obvious that you're missing an End Select for the second Select Case block and an End If for the If statement.

But there's more to it than that. The problems starts here, although this is a perfectly valid statement:

strFrame4 = Item.UserProperties(“ITTicketVisibleâ€)

strFrame4 suggests that you want to get a string property, but you don't, do you? ITTicketVisible is a yes/no property, right? THen Item.UserProperties("ITTicketVisible") can return only one of two values, True or False. Hold that thought for now.

Here's the first real problem statement:

Select Case strITTicketVisible

You haven't set any value for strITTicketVisible. Did you mean to use that as the variable name instead of strFrame4?

And another problem statement:

If “ITTicketVisible†= ????WHAT????

"ITTicketVisible" is a string literal. It serves no purpose here at all. In fact, the second Select Case statement has no purpose either. Let's get rid of both of these statements.

This statement also is unnecessary:

Set ITTicketVisible = myPage1.Controls("ITTicketVisible")

Why? Because you already know the value of the control. It's Item.UserProperties("ITTicketVisible"), the value of the yes/no property bound to the check box.

So, let's throw out all the unnecessary statements and keep what's useful:

Sub Item_CustomPropertyChange(ByVal Name)
Select Case Name
Case "ITTicketVisible"
Set myinspector = Item.GetInspector
Set myPage1 = myInspector.ModifiedFormPages("Message")
Set frame4 = myPage1.Controls("Frame4")
Frame4.Visible = Item.UserProperties("ITTicketVisible")
End Select
End Sub

Does that make a little more sense?
--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
D

daphnejean77

Yes, this makes so much more sense. I am getting an error message though.
The form is telling me - invalid character line 2 - why is Select Case Name
invalid? Am I missing something else?
 
S

Sue Mosher [MVP-Outlook]

Try deleting that statement and typing it back in. Also make sure you have only straight quotes in your code, not curly quotes.

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
D

daphnejean77

Perfect, I don't know what was different but it worked, now to make this do
the same thing for the Item Open event handler, the code will appear as.....

Sub Item_Open_CustomPropertyChange(ByVal Name)
Select Case Name
Case "ITTicketVisible"
Set myinspector = Item.GetInspector
Set myPage1 = myInspector.ModifiedFormPages("Message")
Set frame4 = myPage1.Controls("Frame4")
Frame4.Visible = Item.UserProperties("ITTicketVisible")
End Select
End Sub

Is this correct?
 
S

Sue Mosher [MVP-Outlook]

Not quite. Use the Script | Event Handler command to insert the procedure declaration for the Open event. You don't need any Select Case block inside it because you're not reacting to the change in a property. You're reacting to the item opening. What you do need is the four code statements that change the frame visibility.

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
D

daphnejean77

I used the event Handler for the open event and kept only the four code
statements and it looks like this:

Function Item_Open()
Set myinspector = Item.GetInspector
Set myPage1 = myInspector.ModifiedFormPages("Message")
Set Frame4 = myPage1.Controls("Frame4")
Frame4.Visible = Item.UserProperties("ITTicketVisible")
End Function

This isn't working though.
 
S

Sue Mosher [MVP-Outlook]

Again, please be specific about what's not working? Have you tested to see whether the code is running at all, by inserting a MsgBox statement? Have you checked the value of the ITTicketVisible property.

Also remember that the code won't work unless the recipient has access to the published form definition.

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and 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