Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Lotus Notes Teamroom - lotusscript table text/cell color

Status
Not open for further replies.

bmjones2

Technical User
Dec 3, 2008
1
0
0
US
Im really new to using lotusscript, and Notes as well. I am using the Teamroom template database and i am running into some troubles coding. i modified the Teamroom in Domino by adding a basic table into the form, and each cell has a field for the user to input data. I need a certain column of the table, which has the heading "Status", to be able to let the user insert R for red, B for blue, G for green, etc. and have it auto set the color of the cell(ideally) to that corresponding color. I've seemed to have an easier time trying to get the font color to change. But this is what i have so far. Hopefully someone can give me some help with the font color, and maybe with the cell color.

I am coding within one of the fields i need to change, it is named "Untitled_4", and i am using the Exiting event, so when they click off the rich text field it runs the code.

So far all I can get to work is this(just for the color red). I know I can improve it by Trimming spaces and setting it to lowercase, but i'm just trying to get the basics to work. It just replaces the letter 'r' with 'RED':

Sub Exiting(Source As Field)
Dim workspace As New NotesUIWorkspace
Dim uidoc As NotesUIDocument
Set uidoc = workspace.CurrentDocument
If (uidoc.FieldGetText("Untitled_4") = "r") Then
Call uidoc.FieldSetText ( "Untitled_4" , "RED" )
End If
End Sub

However, I need the color of the 'Red' text to be red also. This next part is my attempt at it, but I am getting "Type mismatch" and "Object variable not set" errors. I'm Not sure why though. The "type mismatch" error has to do with the data variable but that's all I know.
Sub Exiting(Source As Field)
Dim session As New NotesSession
Dim db As NotesDatabase
Set db = session.CurrentDatabase

Dim doc As NotesDocument
Set doc = New NotesDocument(db)

Dim data As Variant
data = Lcase(Trim(doc.GetItemValue( "Untitled_4" )))

Dim richStyle As NotesRichTextStyle
Set richStyle = session.CreateRichTextStyle
richStyle.bold = True
richStyle.NotesColor = COLOR_RED

Dim richText As NotesRichTextItem
Set richText = doc.GetFirstItem( "Untitled_4" )

If (data = "r") Then
Call richText.AppendStyle(richStyle)
Call richText.AppendText( "RED" )
End If
End Sub

Any help would be appreciated. thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top