Link to home
Start Free TrialLog in
Avatar of jana
janaFlag for United States of America

asked on

Help on sorting vbAccelaratoe Grid in Outlook 2007 VBA

We place the sorting accordingly.  However, when the results are displayed, it is not really sorted.

This is what we have

 UserForm1.gridItemsFound.SortObject.Clear
 UserForm1.gridItemsFound.ColumnSortOrder(i_DATE) = CCLOrderAscending
 UserForm1.gridItemsFound.SortObject.SortColumn(i_DATE) = 1
 UserForm1.gridItemsFound.Sort

Please advice
Avatar of Chris Raisin
Chris Raisin
Flag of Australia image

OK - I am looking at this one too, tied in with the code I have already supplied you.

Stand By...

Chris
ASKER CERTIFIED SOLUTION
Avatar of Chris Raisin
Chris Raisin
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of jana

ASKER

You are correct, "UserForm1.gridItemsFound.Redraw = False" was missing.

But still doesn't sort.  

We want to sort by a Date instead of Project/Subject:

    UserForm1.gridItemsFound.SortObject.Clear
    UserForm1.gridItemsFound.ColumnSortOrder(i_DATE) = CCLOrderAscending
    UserForm1.gridItemsFound.SortObject.SortColumn(i_DATE) = 1
    UserForm1.gridItemsFound.Sort

The date is converted to string, like "2012-0409 7:59:00 PM" (haven't had the chance to actually convert the column to Date)

Am I missing something?
OK stand by.....
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of jana

ASKER

Sorry about the confusion.  The "Click" on the header sorts the Grid ok.  The problem we have is when the Grid is displayed initially.  When the user first enter the grid and searches for specific, the result is not sorted the columne we need; the Date column.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of jana

ASKER

I replace as you have it, but still no sort.

I think your last entries ID: 37826342 and forward, pertains to a question we placed regarding dates.
I have fixed the sorting date problem.

But first, what date field are you using "SentOn" or "ReceivedTime"?

Cheers
Chris
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of jana

ASKER

We have found this to be even faster.  But I keep getting an error with the form.  Can you send me the UserFrom1?
Avatar of jana

ASKER

The error I keep getting is when exiting the Form

---------------------------
vbAccelerator SGrid II Control
---------------------------
Run-time error '0'
---------------------------
OK  
---------------------------
Avatar of jana

ASKER

Somehow solved it by exiting outlook, deleting the userform and re-importing it; its working.

However we are trying to understand the coding so we can tweak with it.  The collowing are the lines we are wondering what are they for.  Please just give a super brief of each line:


1. user32.dll
2. UserForm1.gridItemsFound.GridLines = True
3. .AddColumn vKey:="ID", sheader:="ID", lcolumnwidth:=20, bVisible:=False
4. .ColumnOrder(1) = GetSetting(Application.Name, "Setup", "ColOrder1", 1)
5. .ColumnWidth(1) = GetSetting(Application.Name, "Setup", "ColWidth1", 400)
6. .ColumnOrder(2) = GetSetting(Application.Name, "Setup", "ColOrder2", 2)
7. .ColumnWidth(2) = GetSetting(Application.Name, "Setup", "ColWidth2", 50)
8. .ColumnOrder(nCol) = GetSetting(Application.Name, "Setup", "ColOrder" + CStr(nCol), nCol)
9. lColIndex(i_SUBJECT) = .ColumnIndex("Subject")
10. Session.Application.ActiveExplorer.Activate
11. UserForm1.Caption = GetSetting(Application.Name, "Setup", "FormCaption", "Search for SUBJECTS")
12. txtSearch.Text = GetSetting(Application.Name, "Setup", "txtSearch", "")
13. nSelectedRow = GetSetting(Application.Name, "Setup", "SelectedRow", 1)
14. nSelectedCol = GetSetting(Application.Name, "Setup", "SelectedCol", 1)
15. UserForm1.MousePointer = fmMousePointerHourGlass
16. gridItemsFound.Sort
17. UserForm1.MousePointer = fmMousePointerDefault
Busy getting answers for you...

Stand By...

Cheers
Chris
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of jana

ASKER

Wow! Thank you very much!

But didn't see answers for questions

9. lColIndex(i_SUBJECT) = .ColumnIndex("Subject")
10. Session.Application.ActiveExplorer.Activate

Please advice
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of jana

ASKER

Just got a chance to escape... we are in closing.

Thanx for the explanations; great info!  You just helped us jump from point A to point B with breeze.