Anybody use Rich TextBox Controls? (1 Viewer)

PaddyIrishMan

Registered User.
Local time
Today, 12:12
Joined
Jun 5, 2002
Messages
166
Hi,
I've replaced a couple of my standard textbox controls with RTB controls to allow formatting of individual lines of text etc.
This is all working fine in Forms.

Due to the way RTB controls work (they store formatting tags within the text in the database) I also have to replace the Textboxes for these fields in my reports with RTB controls.

But....
I can't get the RTB's in the Reports to display any data. When I set the ControlSource to a fieldname & try to display the report I get a 'Property Cannot be Set' message.

Has anybody else worked with RTB controls in this manner before?
Has anybody got any suggestions as to how I can fix this?

Thanks in advance,
Patrick.
 

pdx_man

Just trying to help
Local time
Today, 04:12
Joined
Jan 23, 2001
Messages
1,347
I have used them once before, but that was to manipulate data in a Rich Text File on the network drive. Had nothing to do with formatting text stored in a table in my DB. I didn't think it had that ability. I will look into it further.

(Try double clicking on the control and see if a 'Properties' dialog box come up for it)
 

PaddyIrishMan

Registered User.
Local time
Today, 12:12
Joined
Jun 5, 2002
Messages
166
Thanks pdx_man,
After doing some research, it is a Microsoft bug. It's down to the control being painted before a handle is assigned.

It still works great in Forms though (If you arent going to be using reports to display the data..)

I think Access could do with an intrinsic control which could be used to Bold, Colour, Bullet etc. individual lines of text.

Any ideas how I could still display the formatted text in Reports?
(I've thought of writing a Function to clean the RTF tags from the data before passing the data to the report but I'd say it would be too slow & a lot of effort.)

Regards,
Patrick
 

pdx_man

Just trying to help
Local time
Today, 04:12
Joined
Jan 23, 2001
Messages
1,347
(I've thought of writing a Function to clean the RTF tags from the data before passing the data to the report but I'd say it would be too slow & a lot of effort.)

That would pretty much be the angle I would attempt. Try it out. See what kind of performance you get. Might be surprised ...
 

PaddyIrishMan

Registered User.
Local time
Today, 12:12
Joined
Jun 5, 2002
Messages
166
Nightmare....
I spent a couple of hours writing one this morning only to scrap it later on. There are too many tag combinations to cover & too many pitfalls -
For example Searching & Replacing for a bold tag (/b) can result in other tags being affected: i.e. attrib/ gets messed up as the /b is replaced etc.

I'm at the stage where I think I'll have to scrap the idea completely.
But... it is Friday!! So I don't really care!!
Even so, any further ideas appreciated.

Thanks,
Patrick
 

Fornatian

Dim Person
Local time
Today, 12:12
Joined
Sep 1, 2000
Messages
1,396
Why not create a table or an array variable if you prefer of possible tags to eliminate then loop through these using either DAO or Array manipulation in a for...next loop to eradicate the tags in the stored field prior to presenting. if this was built as a function you could use it in a query to return the plain text. Maybe that's waht you were trying to do. Tell me, is there any measure if we assume that we need to remove all words following /.

Maybe you could post some sample of the rtf for others to work on?
 

PaddyIrishMan

Registered User.
Local time
Today, 12:12
Joined
Jun 5, 2002
Messages
166
Thanks for the response Fornation,
I don't think it's going to be worth the effort involved to write a big function (And I don't have the time)
For anyone interested, here is a (Very) Quick & Dirty example of a Rich TextBox & the RTF tags produced.

If anybody else is interested in pursuing this route, I'd be obliged if you would post your solution.

Regards,
Patrick
 

PaddyIrishMan

Registered User.
Local time
Today, 12:12
Joined
Jun 5, 2002
Messages
166
Bloody attachments!!

Oops
 

Attachments

  • rtf97.zip
    21.1 KB · Views: 222

AngelicGuardian

Village Idiot
Local time
Today, 12:12
Joined
Apr 7, 2003
Messages
43
Well I have a function that removes the tags I use it to store separate data for reports, unfortunitaly it has no formatting :|

Just download it and try it
 

Attachments

  • rtf.zip
    27.3 KB · Views: 206

PaddyIrishMan

Registered User.
Local time
Today, 12:12
Joined
Jun 5, 2002
Messages
166
Looks good!

Thanks!
I'll give it a try when I get some time to implement it.

-Patrick.
 

AngelicGuardian

Village Idiot
Local time
Today, 12:12
Joined
Apr 7, 2003
Messages
43
hat last one had a couple lockup bugs heres the revamped code:
Code:
Function decode(sStr As String) As String
    Dim sTemp, sChar, sChar2 As String
    Dim iCurrentPos, bIgnore, bCmdLine As Integer
    
    iCurrentPos = InStr(1, sStr, ";}}", vbTextCompare) + 3
    sStr = Mid(sStr, iCurrentPos)
    iCurrentPos = InStr(1, sStr, ";}", vbTextCompare) + 4
    sStr = Mid(sStr, iCurrentPos)
    bIgnore = 0
    bCmdLine = 0
    iCurrentPos = 1
    While (iCurrentPos > 0 And iCurrentPos < (Len(sStr) - 9))
        sChar = Mid(sStr, iCurrentPos, 1)
        If ((IsNull(sChar) = True) Or (sChar = "")) Then
            iCurrentPos = -1
        End If
        If (sChar = "{") Then
            bIgnore = bIgnore + 1
            sChar = ""
        End If
        If (sChar = "\") Then
            sChar2 = Mid(sStr, iCurrentPos + 1, 1)
            If (isAlpha(sChar2) = True) Then
                bCmdLine = 1
            Else
                sTemp = sTemp & sChar2
                sChar = ""
                iCurrentPos = iCurrentPos + 1
            End If
        End If
        If (bIgnore = 0 And bCmdLine = 0) Then
            sTemp = sTemp & sChar
        End If
        If (bCmdLine = 1 And sChar = " ") Then
            bCmdLine = 0
        End If
        If (sChar = "}") Then
            bIgnore = bIgnore - 1
            bCmdLine = 0
        End If
        iCurrentPos = iCurrentPos + 1
    Wend
    decode = sTemp
End Function

Function isAlpha(sChar As String) As Boolean
    isAlpha = False
    'to add a star to bulleted text comment out the next 3 lines
    If (sChar = "*") Then   'removes the star from bulleted text
        isAlpha = True      'removes the star from bulleted text
    End If                  'removes the star from bulleted text
    If (sChar = "'") Then
        isAlpha = True
    End If
    If (sChar = "a") Then
        isAlpha = True
    End If
    If (sChar = "b") Then
        isAlpha = True
    End If
    If (sChar = "c") Then
        isAlpha = True
    End If
    If (sChar = "d") Then
        isAlpha = True
    End If
    If (sChar = "e") Then
        isAlpha = True
    End If
    If (sChar = "f") Then
        isAlpha = True
    End If
    If (sChar = "g") Then
        isAlpha = True
    End If
    If (sChar = "h") Then
        isAlpha = True
    End If
    If (sChar = "i") Then
        isAlpha = True
    End If
    If (sChar = "j") Then
        isAlpha = True
    End If
    If (sChar = "k") Then
        isAlpha = True
    End If
    If (sChar = "l") Then
        isAlpha = True
    End If
    If (sChar = "m") Then
        isAlpha = True
    End If
    If (sChar = "n") Then
        isAlpha = True
    End If
    If (sChar = "o") Then
        isAlpha = True
    End If
    If (sChar = "p") Then
        isAlpha = True
    End If
    If (sChar = "q") Then
        isAlpha = True
    End If
    If (sChar = "r") Then
        isAlpha = True
    End If
    If (sChar = "s") Then
        isAlpha = True
    End If
    If (sChar = "t") Then
        isAlpha = True
    End If
    If (sChar = "u") Then
        isAlpha = True
    End If
    If (sChar = "v") Then
        isAlpha = True
    End If
    If (sChar = "w") Then
        isAlpha = True
    End If
    If (sChar = "x") Then
        isAlpha = True
    End If
    If (sChar = "y") Then
        isAlpha = True
    End If
    If (sChar = "z") Then
        isAlpha = True
    End If
End Function
That should fix quite a few problems
 

Mile-O

Back once again...
Local time
Today, 12:12
Joined
Dec 10, 2002
Messages
11,316
AngelicGuardian said:
Code:
Function isAlpha(sChar As String) As Boolean
    isAlpha = False
    'to add a star to bulleted text comment out the next 3 lines
    If (sChar = "*") Then   'removes the star from bulleted text
        isAlpha = True      'removes the star from bulleted text
    End If                  'removes the star from bulleted text
    If (sChar = "'") Then
        isAlpha = True
    End If
    If (sChar = "a") Then
        isAlpha = True
    End If
    If (sChar = "b") Then
        isAlpha = True
    End If
    If (sChar = "c") Then
        isAlpha = True
    End If
    If (sChar = "d") Then
        isAlpha = True
    End If
    If (sChar = "e") Then
        isAlpha = True
    End If
    If (sChar = "f") Then
        isAlpha = True
    End If
    If (sChar = "g") Then
        isAlpha = True
    End If
    If (sChar = "h") Then
        isAlpha = True
    End If
    If (sChar = "i") Then
        isAlpha = True
    End If
    If (sChar = "j") Then
        isAlpha = True
    End If
    If (sChar = "k") Then
        isAlpha = True
    End If
    If (sChar = "l") Then
        isAlpha = True
    End If
    If (sChar = "m") Then
        isAlpha = True
    End If
    If (sChar = "n") Then
        isAlpha = True
    End If
    If (sChar = "o") Then
        isAlpha = True
    End If
    If (sChar = "p") Then
        isAlpha = True
    End If
    If (sChar = "q") Then
        isAlpha = True
    End If
    If (sChar = "r") Then
        isAlpha = True
    End If
    If (sChar = "s") Then
        isAlpha = True
    End If
    If (sChar = "t") Then
        isAlpha = True
    End If
    If (sChar = "u") Then
        isAlpha = True
    End If
    If (sChar = "v") Then
        isAlpha = True
    End If
    If (sChar = "w") Then
        isAlpha = True
    End If
    If (sChar = "x") Then
        isAlpha = True
    End If
    If (sChar = "y") Then
        isAlpha = True
    End If
    If (sChar = "z") Then
        isAlpha = True
    End If
End Function

That's way too long for something so simple.

Code:
Public Function IsAlpha(strChar As String) As Boolean

    On Error Goto Err_IsAlpha

    If Len(strChar) > 1 Then Exit Function

    strChar = StrConv(strChar, vbUpperCase)
    If (Asc(strChar) >= 65 And Asc(strChar) <= 90) Or Asc(strChar) = 42 Then
        IsAlpha = True
    End If

Exit_IsAlpha:
    Exit Function

Err_IsAlpha:
    IsAlpha = False
    Resume Exit_IsAlpha

Exit Function


Also, Angelic, you don't need to set a Boolean to False (to begin with) as False is a Boolean's Default Value.
 
Last edited:

AngelicGuardian

Village Idiot
Local time
Today, 12:12
Joined
Apr 7, 2003
Messages
43
Sorry 'bout that, I didn't know how to access the ascii values

And 'bout the setting the boolean to false I figure better safe then sorry since I'm used to using C++ in which it equals whatever that empty memory contained sometimes true sometimes false

oh yeah and
bIgnore is a Integer
thats what I get for looking at a screen for 8 hours straight
 

Users who are viewing this thread

Top Bottom