How to sort a column in vbAccelerator DataGrid used in Outlook 2007 VBA

We have vbAccelerator DataGrid being used in our Outlook 2007 via VBA.

We are trying to make the Grid be Sorted by the column the user clicks on.  

What is the best method to go about it?
rayluvsAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Chris Raisin(Retired Analyst/Programmer)Commented:
Ok...I'm awake still!  :-)


Sorting is always performed via the SortObject

Do you want to sort on ONE column only?

We could perhaps RIGHT click to set the column to be sorted then LEFT click to have it toggel between ASCENDING and then DESCENDING.

What would you like?

Cheers
Chris
0
rayluvsAuthor Commented:
Hey!!! We though you would be counting sheeps!!

We need that when the user clicks on 'Tasks', the current grid would sort A-Z it's contents by 'Tasks'.  If the user clicks again, would revert the sort Z-A.
0
Chris Raisin(Retired Analyst/Programmer)Commented:
OK...working on it (sleep-typing...not sleep-walking)

Stand By...

Chris
0
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

Chris Raisin(Retired Analyst/Programmer)Commented:
Do you want it to be ONLY for that column, or for any column the user picks?

Cheers
Chris
0
rayluvsAuthor Commented:
any column
0
Chris Raisin(Retired Analyst/Programmer)Commented:
OK - Here it is!  :-)

This must be placed in the code that resides in the UserForm.

There is provision to tweak the code for columns that are sorted by date or icon rather than text, (The default is text)

It is only set for one column at a time at the moment so if you want to "subsort" you can (up to three columns deep) but I will have to work on that code when I finally get up (it is now 5.50am). (You might want to sort on "Subject within Type within Project" perhaps.)
That would be a challenge but I would be happy to try it for you.

Cheers
Chris

Public Sub gridItemsFound_ColumnClick(ByVal lCol As Long)
Dim sTag As String
Dim i As Long

With gridItemsFound.SortObject
  .Clear
  .SortColumn(1) = lCol
  sTag = gridItemsFound.ColumnTag(lCol)
  If (sTag = "") Then
    sTag = "DESC"
    .SortOrder(1) = CCLOrderAscending
  Else
    sTag = ""
    .SortOrder(1) = CCLOrderDescending
  End If
  gridItemsFound.ColumnTag(lCol) = sTag
  Select Case gridItemsFound.ColumnKey(lCol)
    Case "", ""
      ' sort by icon:
      .SortType(1) = CCLSortIcon
    Case ""
      'date columns
      ' sort by date:
      .SortType(1) = CCLSortDate
    Case Else
      ' sort by text:
      .SortType(1) = CCLSortString
  End Select
End With
UserForm1.MousePointer = fmMousePointerHourGlass
gridItemsFound.Sort
UserForm1.MousePointer = fmMousePointerDefault
End Sub

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
rayluvsAuthor Commented:
Ok will check...
0
rayluvsAuthor Commented:
Worked excellently!
0
Chris Raisin(Retired Analyst/Programmer)Commented:
Would you like multiple columns?

Cheers
Chris  (snore!....snore!....zzzzzz....zzzzz)
0
rayluvsAuthor Commented:
By multiple columns, what do you mean specifically?
0
Chris Raisin(Retired Analyst/Programmer)Commented:
Well, when you click on (say) "Projects" then the order could be Tasks sorted alphabetically (does not make much sense) within project, and then "Subject" within each Task.

I think in this exercise it does not make much sense to have multiple sorts, unless you perhaps introduce a "Priority" field such as "1" (Urgent), "2" (high),"3" Medium, "4" (Low),  "5" (Very Low) and then the tasks could be sorted on their priority within a project.

Anyway, I will look at how the sorting works and even if you do not use it, at least I will have that info should others need it at any time.

I think though that since it is quite involved, it should be asked as a new question (should you feel you would like it). I have basically answered this question already.

Did you look at the final code I left in the other question? I think you will find it very beneficial should the user want to actually view the email "double-clicked" upon in the grid.


Cheers
Chris


Cheers
Chris
0
rayluvsAuthor Commented:
I talked to my boss and the current sorting already provided is enough.

We have been running the apps and a series of question surfaced, but will open a new question for that.  This question on sorting has been answered.

Thanx
0
Chris Raisin(Retired Analyst/Programmer)Commented:
OK - I will keep my eyes peeled :-)

Cheers
Chris
0
rayluvsAuthor Commented:
We placed a couple of question regarding sorting and headers.  Please advice
0
Chris Raisin(Retired Analyst/Programmer)Commented:
Have done and am responding.

I have set up a special filter so that whenever you submit a new question, I receive an email advising me of it - EE works pretty efficiently, eh?  :-)

Cheers
Chris
0
rayluvsAuthor Commented:
Yes it does!  That is why I stick to EE!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Outlook

From novice to tech pro — start learning today.