Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Check if the Rich Text Field is empty or not

Posted on 2006-06-06
10
Medium Priority
?
2,618 Views
Last Modified: 2013-12-18
If doc.Attachment(0)="" Then

I've always used the above line to check if a field is filled in or not.

For Rich Text Field it doesn't work because I get an error "Variant doesn't contain a container"

I tried to check it with a Formula like @IsNull or @Contains but I didn't succeed.

@Attachments isn't good either, because there're more attachment fields but only one is required. If @Attachments returns 1, then I don't know if the required field is filled in or the user attached a file to another field which isn't required.
0
Comment
Question by:didier20
  • 3
  • 3
  • 2
8 Comments
 
LVL 46

Accepted Solution

by:
Sjef Bosman earned 140 total points
ID: 16841755
Some ideas:
    http://www.keysolutions.com/NotesFAQ/howif.html
    http:Q_21226663.html "Checking if a Field is NULL!"
0
 
LVL 22

Expert Comment

by:mbonaci
ID: 16841870
Hi didier20,

Function IsRTFNull(rtfield As String) As Integer
    'This function tests a Rich Text field to see whether or not it
    'is null. It returns TRUE if the field is null, and returns
    'FALSE if the field is not null. It works even if the rich
    'text field contains a file attachment, doclink, or OLE
    'object but does not contain any 'text.

    On Error Goto Errhandle

    Dim workspace As New NotesUIWorkspace
    Dim uidoc As NotesUIDocument
    Set uidoc = workspace.CurrentDocument

    Call uidoc.ExpandAllSections
    'This is only needed if your field is in a section that may be closed when this executes

    Call uidoc.GotoField(rtfield)
    Call uidoc.SelectAll

    'The next line will generate a 4407 error message if the Rich Text Field is null

    Call uidoc.DeselectAll

    IsRTFNull = False

    Exit Function


Errhandle:
    Select Case Err
    Case 4407
        'the DeselectAll line generated an error message, indicating that the rich text field does not contain anything
        If currentfield <> "" Then
            Call uidoc.GotoField(currentfield)
        End If
        IsRTFNull = True
        Exit Function
    Case Else
        'For any other error, force the same error to cause LotusScript to do the error handling
        Error Err
    End Select
End Function

Hope this helps,
Marko
0
 
LVL 46

Expert Comment

by:Sjef Bosman
ID: 16841911
Well, interesting... I'd say you had 20 minutes to follow my first link... :)
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:didier20
ID: 16842434
I think I should replace "rtfield" (in the above code ) with the field name in my db where the attachment is.

Or should I replace the "currentfield"?

It returns True or false but How can I see it? Message window or a field value will be changed?
I pasted the Code but I notice no change.
0
 
LVL 22

Assisted Solution

by:mbonaci
mbonaci earned 80 total points
ID: 16842499
didier20,
position the cursor in Globals - Declarations (at the end, if Declarations isn't empty) and paste the whole function.

Then from the place you want to check if the RTF is empty call the function, like this:

    If IsRTFNull( "YourRTFfieldName" ) Then
        'whatever you want done
    End If

Hope this helps,
Marko
0
 

Author Comment

by:didier20
ID: 16849768
Thanks,

It works like a charm.
To be honest, I didn't believe that I can make it work after reading the below lines.

(the exception would be rich text fields, which are just about impossible to check for emptiness. The rest you can do, usually, is check the .Text value of them, and see if it is a blank string, which could be a bad test if the field contains just an embedded Excel file or a bitmap image.
)
0
 
LVL 46

Expert Comment

by:Sjef Bosman
ID: 16849918
> ...just about impossible...
so it's doable...

Great!
0
 
LVL 22

Expert Comment

by:mbonaci
ID: 16850200
The problem here is that I didn't follow the link.
I just posted the code from my Code library (http://www.openntf.org/Projects/pmt.nsf/ProjectLookup/Code%20Library).
Sorry Sjef (I could've explained earlier).

I've used it here a couple of days ago:
http://www.experts-exchange.com/Applications/Email/Lotus_Notes_Domino/Q_21838852.html

Bad mod...
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Problem "Can you help me recover my changes?  I double-clicked the attachment, made changes, and then hit Save before closing it.  But when I try to re-open it, my changes are missing!"    Solution This solution opens the Outlook Secure Temp Fold…
Sometimes clients can lose connectivity with the Lotus Notes Domino Server, but there's not always an obvious answer as to why it happens.   Read this article to follow one of the first experiences I had with Lotus Notes on a client's machine, my…
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
Suggested Courses

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question