MultiMedia Communications International

Los Angeles :: Washington :: London

 
Access - Sorting a ColumnHistory field PDF Print E-mail
Written by Administrator   
Saturday, 01 August 2009 05:29

In Access 2007 one of the supplied templates enables the creation of an Issues database to track Project Issues. The "comments" column uses the "Column History" feature to maintain a list of previous comments.

The Column History feature lists the results in Oldest to Newest order. This is not really practical since we are most like to want to see the recent comments at teh top of the list and not have to scroll through to find them.

I went out on the Internet to see if someone had cracked this problem. Pretty much every article said that there was no way to sort the results of Column History.

If the data is being returned and has a date stamp then there must be a way to sort it into descending date order and present the results listed from newest to oldest.

Also for the Issues database to have any practical use there needed to be a way of author stamping the comments.

The status column could benefit from some extra entries that indicate things like "Question" and who the question is directed at. Then the column can be used to select only comments or questions that need to be addressed by a specific individual.

Of course with significant extra development a full issues tracking system can be created, the idea here was to use the free template to build a system that is functional even if it needs a little work on the part of the participants.

You can follow this link to a zipped version of the Microsoft Access database with the changes to handle sorting the Column History and adding a Comment Author tag.

Specifics of how it was done :

The Issues_Details form_current event calls a routine called splitLines as detailed below.

Private Sub splitLines()
' sorts Comments Memo field history in newest to oldest order and seperates each entry with a blank line
'=ColumnHistory([RecordSource],"Comments","[ID]=" & Nz([ID],0))
Dim x As String
Dim y() As String
Dim i As Integer
x = ColumnHistory([RecordSource], "Comments", "[ID]=" & Nz([ID], 0))
y = Split(x, "[Version")
txtComments.Value = ""
For i = UBound(y) To 0 Step -1
If Len(y(i)) > 0 Then
txtComments.Value = txtComments.Value & "[Version" & y(i)
If Right(y(i), 2) <> vbCrLf Then
txtComments.Value = txtComments.Value & vbCrLf
End If
txtComments.Value = txtComments.Value & vbCrLf ' added to make more readable
End If
Next
End Sub

Each comment is loaded into the txtComments field on the form in reverse order, this will place the newest at the top and the oldest at the bottom. An extra carriage return & line feed is added to the end of each comment to make the list more readable.

 

 

Last Updated on Saturday, 01 August 2009 06:28