Serius Problem with HideFormPage Method

A

apextos

After using the HideFormPage method to hide a ModifiedPagesForm, if we Show
this form again using ShowForm, controls like ComboBoxes does not have any
more possible values. Either we populate this Combobox from ADO with get
rows or filling them with addItem.

For simplicity reasons try the follwing code and check what are the possible
values at this combobox.

We asume that we have a page with name Page1 and a combobox with name
Combobox1.

==============================================

Function Item_Open()

Dim objPage1, cboField

Set objPage1 = Item.GetInspector.ModifiedFormPages("Page1")
Set cboField = objPage1.Controls("ComboBox1")

Item.GetInspector.ShowFormPage "Page1"
Item.GetInspector.SetCurrentFormPage "Page1"

cboField.AddItem
cboField.AddItem
cboField.Column ( 0, 0 ) = "Central"
cboField.Column ( 0, 1 ) = "Test"

Item.GetInspector.HideFormPage "Page1"
Item.GetInspector.ShowFormPage "Page1"
Item.GetInspector.SetCurrentFormPage "Page1"


End Function


================================

Test it with both Outlook 2000 & 2003

----------------
This post is a suggestion for Microsoft, and Microsoft responds to the
suggestions with the most votes. To vote for this suggestion, click the "I
Agree" button in the message pane. If you do not see the button, follow this
link to open the suggestion in the Microsoft Web-based Newsreader and then
click "I Agree" in the message pane.

http://www.microsoft.com/communitie...4ee&dg=microsoft.public.outlook.program_forms
 
A

apextos

Maybe When Microsoft release Office 2020 or 2075 or something will solve
that BUG.

I'm convinced that there will be no answer from Microsoft but at least they
can remove HideFormPage as a method.

DOES NOT only initialize these controls but after that method even trying to
Set BackColor to one of them does not work .....

.........
 
S

Sue Mosher [MVP-Outlook]

Show a code snippet?

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

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

apextos

Lets take the standard Contact Form. Enable p.2 and p.3, rename them as Page2
and Page3.

Chose , from field choser, the field FirstName putting it at Page2 and
create a button with name ButtonOnPage2.

Chose field LastName and put it at Page3, also a command button with name
ButtonOnPage3.

Try color changes without pressing Button2 or Button3, works perfect. After
that try pressing button2, this will hide page2 and switch to page3 and vise
versa with button3.

After that try whatever you like with the controls. THEY DON't change

Thanks

===================================================






'*******************************
' Global Declarations
'*******************************
Option Explicit

Dim myInspector, myPages
Dim objPage2
Dim objPage3
Dim cboField
Dim myColorRed : myColorRed = &h008282ff
Dim myColorBlue : myColorBlue = &h00ffc891
Dim myColorYellow : myColorYellow = &h0080ffff
Dim myColorGreen : myColorGreen = &h00808040


'*******************************
' Open Event
'*******************************

Function Item_Open()

Call InitControlObjects()

END Function


Sub InitControlObjects()

Set myInspector = Item.GetInspector
Set myPages = myInspector.ModifiedFormPages
Set objPage2 = myPages("Page2")
Set objPage3 = myPages("Page3")

Set cboField = objPage2.Controls("FirstName")
cboField.BackColor = myColorYellow : Set cboField = Nothing

Set cboField = objPage3.Controls("LastName")
cboField.BackColor = myColorYellow : Set cboField = Nothing

myInspector.SetCurrentFormPage "Page2"
myInspector.ShowFormPage "Page2"


End Sub


Sub ButtonOnPage2_Click()

myInspector.HideFormPage "Page2"
myInspector.ShowFormPage "Page3"
myInspector.SetCurrentFormPage "Page3"

End Sub

Sub ButtonOnPage3_Click()

myInspector.HideFormPage "Page3"
myInspector.ShowFormPage "Page2"
myInspector.SetCurrentFormPage "Page2"

End Sub


Sub Item_PropertyChange(ByVal Name)

Select Case Name


Case "FirstName"
Set cboField = objPage2.Controls("FirstName")
IF Item.FirstName = "Sue" Then
cboField.Backcolor = myColorRed
Else
cboField.Backcolor = myColorGreen
END IF
Set cboField = Nothing

Case "LastName"
Set cboField = objPage3.Controls("LastName")
IF Item.LastName = "Mosher" Then
cboField.Backcolor = myColorBlue
Else
cboField.Backcolor = myColorGreen
END IF
Set cboField = Nothing

End Select

End Sub
 
S

Sue Mosher [MVP-Outlook]

Add code to your button Click event handlers to reinstantiate objPage2 and objPage3 after you redisplay them:

Sub ButtonOnPage2_Click()
myInspector.HideFormPage "Page2"
myInspector.ShowFormPage "Page3"
myInspector.SetCurrentFormPage "Page3"

Set myInspector = Item.GetInspector
Set myPages = myInspector.ModifiedFormPages
Set objPage3 = myPages("Page3")
End Sub

Sub ButtonOnPage3_Click()
myInspector.HideFormPage "Page3"
myInspector.ShowFormPage "Page2"
myInspector.SetCurrentFormPage "Page2"

Set myInspector = Item.GetInspector
Set myPages = myInspector.ModifiedFormPages
Set objPage2 = myPages("Page2")
End Sub

You might also want to include code to display the desired background color for the control when the page is redisplayed.

In other words, you need to do much the same thing when you redisplay the page that you did to initialize the controls when the form opens.

--
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