Question

I'm working on changing an Access 2010 report. There is a portion of the report that reads in Raw Data from a SharePoint field called "Notes" that has comments for each record. Within the "notes" field, there can be several sentences. I need to find a way to separate those sentences into a bullet point per sentence in my report.

I'm trying to come up with a clever way to do so. I can get the data entry folks to use a symbol of some sort in the raw that signifies the need for a new bullet. This way, in my Report Expression (or perhaps via VBA), I can get it separated... but how?

Any thoughts?

Was it helpful?

Solution 2

In its most rudimentary form you could do something like the following. Is splits the [Notes] text on ". " and creates a separate "point" for each sentence.

Sample Data: [SharePointData]

SlideNumber  Notes                               
-----------  ------------------------------------
          1  Title slide.                        
          2  Brief overview. Just the highlights.
          3  More stuff.

VBA Code:

Option Compare Database
Option Explicit

Public Function SplitNoteText(RawText As Variant) As Variant
    Dim rtn As Variant, StringArray() As String, Point As Variant
    Const BulletChar = "-"
    rtn = Null
    If Not IsNull(RawText) Then
        rtn = ""
        StringArray = Split(RawText, ". ", -1, vbBinaryCompare)
        For Each Point In StringArray
            If Len(Point) > 0 Then
                If Len(rtn) > 0 Then
                    rtn = rtn & vbCrLf & vbCrLf
                End If
                rtn = rtn & BulletChar & " " & Point
                If Right(Point, 1) <> "." Then
                    ' add back the period that got "consumed" in the Split
                    rtn = rtn & "."
                End If
            End If
        Next
    End If
    SplitNoteText = rtn
End Function

Test query:

SELECT SlideNumber, Notes, SplitNoteText(Notes) AS Points FROM SharePointData;

Results:

SlideNumber  Notes                                 Points                                     
-----------  ------------------------------------  ----------------------
          1  Title slide.                          - Title slide.                             
          2  Brief overview. Just the highlights.  - Brief overview.

                                                   - Just the highlights.
          3  More stuff.                           - More stuff.                              

OTHER TIPS

The memo data field in MS Access can be set to Rich Text as a property, so:

 UPDATE Table1 
 SET Table1.AMemo = "<ul><li>" & 
     IIf(InStr([AMemo],".")>0,
     Replace(Mid([AMemo],1,Len([AMemo])-1),".","</li>"),[AMemo]) & "</li></ul>"

RichText

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top