1

Re: Textual irritation

I don't know if this problem is a bug or something we just have to live with, but it is irritating when inspecting the R6 (and R2002) database via Access.  The problem appears to affect all text boxes where you can add free text via the Recorder interface.  An example is the DESCRIPTION field in the SURVEY table (also COMMENT in TAXON_OCCURRENCE).

In R6 the desired text is shown as wanted.  In Access - if and only if there has been an attempt to edit the field content via the Recorder interface, an attempt including typing a space and deleting it - the field contents in Access are shown as similar to:
{\rtf1\ansi\ansicpg1252\deff0\deflang2057{\fonttbl{\f0\fnil\fcharset0 MS Sans Serif;}{\f1\fnil MS Sans Serif;}}
{\colortbl ;\red0\green0\blue0;}

The *desired* text is hidden unless you use Shift/f2 to open the edit window, when you see (<> contains the actual text of the field):
{\rtf1\ansi\ansicpg1252\deff0\deflang2057{\fonttbl{\f0\fnil\fcharset0 MS Sans Serif;}{\f1\fnil MS Sans Serif;}}
{\colortbl ;\red0\green0\blue0;} \viewkind4\uc1\pard\cf1\f0\fs16 <Survey description text>.\f1 \par }.

This makes inspection difficult, and although you can filter on the hidden text, and on the text of the coding string, it is not possible to clear the extraneous text by S&R from Access (I don't understand that either!). 

If you edit direct from Access, or import the fields from the wizard, there is no visible coding.

Any solution either to disable the phenomenon or to do a global correction on the field would be welcome.

Murdo

2

Re: Textual irritation

Hi Murdo,

What you are seeing is the RTF encoding added to these fields to allow you to store rich text such as bold, italic etc. It's a necessary part of the data for fields which contain anything other than plain text.

It might be possible for the fields to store plaintext if there is no formatting in the text which would make it easier to inspect in most cases - that's probably something for Dorset Software and JNCC to consider. Another idea, though probably much more significant to change, would be to switch to using HTML fragments, which would look like plaintext unless you added any formatting anyway.

Best Wishes

John van Breda
Biodiverse IT

3

Re: Textual irritation

Thanks for that quick response, John.  I realised what the coding was, and what it would allow, but in view of what you say it would seem to me that the ability to use rich text in these fields (does anyone?) does not justify the inconvenience of the consequences.  One for the software developers, perhaps.

Murdo

4

Re: Textual irritation

Hello Murdo

When I was working for the British Dragonfly Society I was given a set of VBA functions that strip out the RTF encoding. If these are of use I could see if I can find them again

Best wishes
Graham
NBN Technical Liaison Officer

5

Re: Textual irritation

Thanks, Graham.  Great - if it is not too much trouble.  I have just manually edited a couple of hundred comments that I discovered had been rtf formatted (long evenings and nothing on the box!), but it may happen again or to others.  Maybe they should be made available on the Forum in case anyone else has the problem.

Murdo

6

Re: Textual irritation

Thanks for these comments - I have logged this as an issue to look into.

Lynn

7

Re: Textual irritation

Below is the function I use to remove rtf formatting in Access. Load this into an Access module so that you can call it in queries  eg fnRemoveRtf([Location].[Description]) . For reporting this is all you need to do, but if you wish to actually edit the data then include both the original columns and the formatted column in your query.  You can then copy and paste the formatted column into the original column and edit it there.  Alternatively, but not  recommended,  you can remove all the formatting from a field  in the  database by running an update query replacing the field with the unfomatted  version. eg Update Location set Location.description = fnremovertf(Location.description).  The point to note is that if you subsequently edit the record in Recorder the formatting will be added back.

For us in XML reports in Recorder 6  there is a User Defined function in the SQL Server database which will remove the formatting  (.ufn_RtfToPlaintext).

ACCESS FUNCTION

Public Function fnRemoveRtf(sRtfin As Variant) As Variant
Dim iState As Integer
Dim isState As Integer
Dim sdate As String
Dim x As Integer
If Left(sRtfin, 5) <> "{\rtf" Or IsNull(sRtfin) = True Then
   fnRemoveRtf = sRtfin
Else
   For x = 1 To Len(sRtfin)
      Select Case Mid$(sRtfin, x, 1)
      Case Is = "{"
          iState = iState + 1
         isState = 0
     Case Is = "}"
          iState = iState - 1
         isState = 0
    Case Is = "\"
         If iState = 1 Then
           If x <> 0 Then
                If Mid$(sRtfin, x - 1, 1) = "\" And isState = 1 Then
                    fnRemoveRtf = fnRemoveRtf & Mid$(sRtfin, x, 1)
                    isState = 0
                Else
                    isState = 1
                End If
            End If
         End If
    Case Is = " ", Chr$(10), Chr$(13)
      If iState = 1 Then
           If isState = 1 Then
                   isState = 0
         
            Else
                    fnRemoveRtf = fnRemoveRtf & " "
       
            End If
      End If
     Case Else
       If iState = 1 Then
         If isState = 0 Then
                 
       
           fnRemoveRtf = fnRemoveRtf & Mid$(sRtfin, x, 1)
       
        End If
      End If
       
   
   End Select
Next
fnRemoveRtf = Trim$(fnRemoveRtf)

End If

End Function

Mike

Mike Weideli

8

Re: Textual irritation

Hello Murdo

I have uploaded the VBA functions I was given to strip RTF. Copy and paste all these into a module in Access. The main function to run in an Access query is FullTextFromRTF.

Best wishes
Graham
NBN Technical Liaison Officer

9

Re: Textual irritation

Thanks, Graham and Mike.  It seems the easy answer would be to get the rtf facility disabled at source.  All this does not seem worth the fun of having your Survey descriptions in fancy format text.

M.

10

Re: Textual irritation

Hi All,

Evidently there is a Recorder function that can remove the rtf - the information about the function is located in the installation guide. See forum post for background and link to installation guides: http://forums.nbn.org.uk/viewtopic.php?pid=3684#p3684.

Cheers,
Lynn