Sort does not work on user defined fields

  • Thread starter Thread starter Mark W
  • Start date Start date
M

Mark W

Hello, I am loading a combobox control with values read fm
another folder and the values always seem to load in
alphabetical order by subject. I would like to sort them
by a user defined field first, then load them. Here is
the code I am using to sort but the data still sorts by
subject. pItems is my collection from the folder I am
reading the data from.
pItems.Sort "[Name]", False
Thank you in advance for your help.
 
That should work, assuming that Name is a field defined in the folder, not
just in individual items. Could you show a little more of your code?
 
Here is the entire subroutine. There are 4 items that get
returned as pItems, 2 Active and 2 Listed.

sub loadCombobox()
dim pFolder,pItems,i,mCtl
' on error resume next
set pFolder = ParentFolder.folders("Ops")
set mCtl = Item.GetInspector.ModifiedFormPages
("Marketing").controls("cboPropertyName")
set pItems = pFolder.items.restrict("[Op Status]
= 'Active' OR [Op Status] = 'Listed'")
pItems.Sort "[Name]", False
for i = 1 to pItems.count
mCtl.additem pItems(i).UserProperties.find("Name")
next
set mCtl = nothing
set pItems = nothing
set pFolder = nothing
end sub
-----Original Message-----
That should work, assuming that Name is a field defined in the folder, not
just in individual items. Could you show a little more of your code?

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



Hello, I am loading a combobox control with values read fm
another folder and the values always seem to load in
alphabetical order by subject. I would like to sort them
by a user defined field first, then load them. Here is
the code I am using to sort but the data still sorts by
subject. pItems is my collection from the folder I am
reading the data from.
pItems.Sort "[Name]", False
Thank you in advance for your help.


.
 
Do you get the same result if you use a For Each ... Next loop instead of
for i = 1 to pItems.count?

Is [Name] a field defined on the folder, i.e. one whose data is visible in a
folder view?

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



Mark W said:
Here is the entire subroutine. There are 4 items that get
returned as pItems, 2 Active and 2 Listed.

sub loadCombobox()
dim pFolder,pItems,i,mCtl
' on error resume next
set pFolder = ParentFolder.folders("Ops")
set mCtl = Item.GetInspector.ModifiedFormPages
("Marketing").controls("cboPropertyName")
set pItems = pFolder.items.restrict("[Op Status]
= 'Active' OR [Op Status] = 'Listed'")
pItems.Sort "[Name]", False
for i = 1 to pItems.count
mCtl.additem pItems(i).UserProperties.find("Name")
next
set mCtl = nothing
set pItems = nothing
set pFolder = nothing
end sub
-----Original Message-----
That should work, assuming that Name is a field defined in the folder, not
just in individual items. Could you show a little more of your code?

Hello, I am loading a combobox control with values read fm
another folder and the values always seem to load in
alphabetical order by subject. I would like to sort them
by a user defined field first, then load them. Here is
the code I am using to sort but the data still sorts by
subject. pItems is my collection from the folder I am
reading the data from.
pItems.Sort "[Name]", False
Thank you in advance for your help.


.
 
I do get the same result if I use For Each. [Name] is
defined in the folder and the data is visible when that
field is used as a column in the folder view.
Thanks, Mark
-----Original Message-----
Do you get the same result if you use a For Each ... Next loop instead of
for i = 1 to pItems.count?

Is [Name] a field defined on the folder, i.e. one whose data is visible in a
folder view?

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



Here is the entire subroutine. There are 4 items that get
returned as pItems, 2 Active and 2 Listed.

sub loadCombobox()
dim pFolder,pItems,i,mCtl
' on error resume next
set pFolder = ParentFolder.folders("Ops")
set mCtl = Item.GetInspector.ModifiedFormPages
("Marketing").controls("cboPropertyName")
set pItems = pFolder.items.restrict("[Op Status]
= 'Active' OR [Op Status] = 'Listed'")
pItems.Sort "[Name]", False
for i = 1 to pItems.count
mCtl.additem pItems(i).UserProperties.find("Name")
next
set mCtl = nothing
set pItems = nothing
set pFolder = nothing
end sub
-----Original Message-----
That should work, assuming that Name is a field defined in the folder, not
just in individual items. Could you show a little more
of
your code?
Hello, I am loading a combobox control with values
read
fm
another folder and the values always seem to load in
alphabetical order by subject. I would like to sort them
by a user defined field first, then load them. Here is
the code I am using to sort but the data still sorts by
subject. pItems is my collection from the folder I am
reading the data from.
pItems.Sort "[Name]", False
Thank you in advance for your help.




.


.
 
Outlook version and build #? I'll see if I can duplicate the issue here.

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



Mark W said:
I do get the same result if I use For Each. [Name] is
defined in the folder and the data is visible when that
field is used as a column in the folder view.
Thanks, Mark
-----Original Message-----
Do you get the same result if you use a For Each ... Next loop instead of
for i = 1 to pItems.count?

Is [Name] a field defined on the folder, i.e. one whose data is visible in a
folder view?

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



Here is the entire subroutine. There are 4 items that get
returned as pItems, 2 Active and 2 Listed.

sub loadCombobox()
dim pFolder,pItems,i,mCtl
' on error resume next
set pFolder = ParentFolder.folders("Ops")
set mCtl = Item.GetInspector.ModifiedFormPages
("Marketing").controls("cboPropertyName")
set pItems = pFolder.items.restrict("[Op Status]
= 'Active' OR [Op Status] = 'Listed'")
pItems.Sort "[Name]", False
for i = 1 to pItems.count
mCtl.additem pItems(i).UserProperties.find("Name")
next
set mCtl = nothing
set pItems = nothing
set pFolder = nothing
end sub
-----Original Message-----
That should work, assuming that Name is a field defined
in the folder, not
just in individual items. Could you show a little more of
your code?
message
Hello, I am loading a combobox control with values read
fm
another folder and the values always seem to load in
alphabetical order by subject. I would like to sort
them
by a user defined field first, then load them. Here is
the code I am using to sort but the data still sorts by
subject. pItems is my collection from the folder I am
reading the data from.
pItems.Sort "[Name]", False
Thank you in advance for your help.




.


.
 
Microsoft Outlook 2000 SP-3 (9.0.0.6627)
I have run into this in the past but have not had time to
investigate it until now. Thanks for your help.
Mark
-----Original Message-----
Outlook version and build #? I'll see if I can duplicate the issue here.

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



I do get the same result if I use For Each. [Name] is
defined in the folder and the data is visible when that
field is used as a column in the folder view.
Thanks, Mark
-----Original Message-----
Do you get the same result if you use a For Each ...
Next
loop instead of
for i = 1 to pItems.count?

Is [Name] a field defined on the folder, i.e. one whose data is visible in a
folder view?

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



Here is the entire subroutine. There are 4 items
that
get
returned as pItems, 2 Active and 2 Listed.

sub loadCombobox()
dim pFolder,pItems,i,mCtl
' on error resume next
set pFolder = ParentFolder.folders("Ops")
set mCtl = Item.GetInspector.ModifiedFormPages
("Marketing").controls("cboPropertyName")
set pItems = pFolder.items.restrict("[Op Status]
= 'Active' OR [Op Status] = 'Listed'")
pItems.Sort "[Name]", False
for i = 1 to pItems.count
mCtl.additem pItems(i).UserProperties.find("Name")
next
set mCtl = nothing
set pItems = nothing
set pFolder = nothing
end sub
-----Original Message-----
That should work, assuming that Name is a field defined
in the folder, not
just in individual items. Could you show a little
more
of
your code?


message
Hello, I am loading a combobox control with values read
fm
another folder and the values always seem to load in
alphabetical order by subject. I would like to sort
them
by a user defined field first, then load them.
Here
is
the code I am using to sort but the data still
sorts
by
subject. pItems is my collection from the folder I am
reading the data from.
pItems.Sort "[Name]", False
Thank you in advance for your help.




.



.


.
 
Doh! Sort doesn't work on user-defined fields. Says so right in Help. (Yes,
it pays to read Help once in a while.) So, you have two choices. One is to
put the data you want to sort by into a built-in field. (BillingInformation
and Mileage are available on all Outlook items.) The other is to retrieve
the unsorted data, put it into an array, then sort the array using one of
the many available algorithms for that.
(http://www.4guysfromrolla.com/webtech/012799-2.shtml is the first one that
came up in my Google search). Then set the combo box's List property to the
(now sorted) array.

--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
message
Here is the entire subroutine. There are 4 items that
get
returned as pItems, 2 Active and 2 Listed.

sub loadCombobox()
dim pFolder,pItems,i,mCtl
' on error resume next
set pFolder = ParentFolder.folders("Ops")
set mCtl = Item.GetInspector.ModifiedFormPages
("Marketing").controls("cboPropertyName")
set pItems = pFolder.items.restrict("[Op Status]
= 'Active' OR [Op Status] = 'Listed'")
pItems.Sort "[Name]", False
for i = 1 to pItems.count
mCtl.additem pItems(i).UserProperties.find("Name")
next
set mCtl = nothing
set pItems = nothing
set pFolder = nothing
end sub
-----Original Message-----
That should work, assuming that Name is a field defined
in the folder, not
just in individual items. Could you show a little more
of
your code?


message
Hello, I am loading a combobox control with values
read
fm
another folder and the values always seem to load in
alphabetical order by subject. I would like to sort
them
by a user defined field first, then load them. Here
is
the code I am using to sort but the data still sorts
by
subject. pItems is my collection from the folder I am
reading the data from.
pItems.Sort "[Name]", False
Thank you in advance for your help.




.



.


.
 
Back
Top