Question on Coding an Outlook Form

  • Thread starter Thread starter Blue
  • Start date Start date
B

Blue

Hello All,

I'm trying to make one of my textboxes visible only if a certain option
button is selected. Currently I have the textbox set to hidden in the
properties...I just don't know how to script this event in outlook...I
thought something like this would work:

If optSpecial1 = True Then
txtSpecial.Visible = True
End If

But it didn't or maybe I'm missing something...So if anyone can lead me to
the right direction that I would appreiciate it...Thank you in advance

Blue
 
You're close.

If you want this text box to show or hide based on a change to a value on a
form, you'll need to use the Custom Property Change event.

Sub Item_CustomPropertyChange (ByVal Name)

Select Case Name
Case "NameOfField"
If Item.userProperties.Find("NameOfField").Value = "X" then

Item.ModifiedFormPages("PageName").Controls("ControlName").Visible = 0
End If
End Select

End Sub

This sub is pretty strict about how it's configured. Don't change the word
Name in the opening line of the sub or the opening line of the Select Case
statement.

--
Patricia Cardoza
Outlook MVP
Author - Special Edition Using Microsoft Office Outlook 2003
Lead Author - Access 2003 VBA Programmer's Reference
Author - Absolute Beginner's Guide to Microsoft OneNote 2003

http://blogs.officezealot.com/cardoza
 
Patricia thank you for the reply...Over the weekend, after trying many different things I got this to work a different way than you did (On Outlook 2000, but for some reason 2003 it didn't work)...The way I used is below:

Dim txtSpecial
Dim txtHowMany
Dim mobjOptButControls

Function Item_Open()

Dim objInsp
Set objInsp = Item.GetInspector

' set controls collection(s) and unbound text boxes
Set mobjOptButControls = objInsp.ModifiedFormPages("Message").Controls
Set txtSpecial = mobjOptButControls("txtSpecial")
Set txtHowMany = mobjOptButControls("txtHowMany")

Set objInsp = Nothing

End Function

Sub optSpecial1_Click()
txtSpecial.Visible = True
mobjOptButControls("txtSpecial").Text = ""
End Sub

Sub OptSpecial2_Click()
txtSpecial.Visible = False
End Sub

Sub optExtra1_Click()
txtHowMany.Visible = True
mobjOptButControls("txtHowMany").Text = ""
End Sub

Sub optExtra2_Click()
txtHowMany.Visible = False
End Sub

Do you have any idea why the above code isn't working in Outlook 2003? Also the code you posted...I was reading somewhere that you only have to use PropertyChange when a control is connect to a database...Is there any truth to that?
 
Back
Top