Good day,
I'll start by saying I work for a small company and have no official training in Notes everything I know I've learned buy trial and error & using other peoples codes.
Application: We have a purchase order database that has been running for a very long time and threw the ages people put in supplier names diffirently. Now I found a code that goes into the selected forms and changes the field values which is exactly what I need the only problem is it's single line. The field I want to update have about 5 text lines (Company name, Tel No etc..) and the original programer put all off the info in one field.
Question: Is there a way in the script linked below how I can make each prompt input go into a diffirent line.I tried a few thing and I think I may be missing something obvious.(If I try chr(10);chLv all I get is either the 2 values next to each other or get them seperated by a comma)
` Sub Initialize Dim ws As New NotesUIWorkspace Dim session As New NotesSession Dim prompt As String Dim fieldName As String Dim fieldValue As String Dim dataTypes As Variant Dim thisDataType As String Dim fieldValues As Variant Dim newFieldValues As Variant Dim db As NotesDatabase Dim coll As NotesDocumentCollection Dim i As Integer Dim doc As NotesDocument Dim item As NotesItem
prompt = "Please enter the name of the field to be updated"
fieldName = ws.Prompt(3, "Enter Field Name", prompt, "")
If fieldName = "" Then Exit Sub
If Instr(fieldName, " ") <> 0 Then
prompt = "Error! Field Names can't have spaces!"
Msgbox prompt, 16, "Error"
Exit Sub
End If
prompt = "Please enter the new value. For multiple values, separate with a colon."
Value1 =ws.Prompt(3, "Enter Field Value", prompt, "")
Value2= ws.Prompt(3, "Enter Field Value", prompt, "")
Fieldvalue=value1 + Chr(10) +value2
Redim dataTypes(5) As String
dataTypes(0) = "Text"
dataTypes(1) = "Number"
dataTypes(2) = "Date"
dataTypes(3) = "Readers"
dataTypes(4) = "Authors"
dataTypes(5) = "DELETE THIS FIELD"
prompt = "Choose the data type of the value(s)"
thisDataType = ws.Prompt(4, "Choose Data Type", prompt, dataTypes(0), dataTypes)
If thisDataType = "" Then Exit Sub
Set db = session.CurrentDatabase
Set coll = db.UnprocessedDocuments
fieldValues = Evaluate({@Explode("} & fieldValue & {"; ":")})
Select Case thisDataType
Case dataTypes(0) : Redim newFieldValues(Ubound(fieldValues)) As String
Case dataTypes(1) : Redim newFieldValues(Ubound(fieldValues)) As Double
Case dataTypes(2) : Redim newFieldValues(Ubound(fieldValues)) As Variant
Case dataTypes(3) : Redim newFieldValues(Ubound(fieldValues)) As String
Case dataTypes(4) : Redim newFieldValues(Ubound(fieldValues)) As String
End Select
For i = Lbound(fieldValues) To Ubound(fieldValues)
Select Case thisDataType
Case dataTypes(0) : newFieldValues(i) = Trim(fieldValues(i))
Case dataTypes(1) : newFieldValues(i) = Val(fieldValues(i))
Case dataTypes(2) : newFieldValues(i) = Cdat(fieldValues(i))
Case dataTypes(3) : newFieldValues(i) = Trim(fieldValues(i))
Case dataTypes(4) : newFieldValues(i) = Trim(fieldValues(i))
End Select
Next
Set doc = coll.GetFirstDocument
While Not doc Is Nothing
If thisDataType = "DELETE THIS FIELD" Then
If doc.HasItem(fieldName) Then Call doc.RemoveItem(fieldName)
Else
Call doc.ReplaceItemValue(fieldName, newFieldValues)
If thisDataType = dataTypes(3) Or thisDataType = dataTypes(4) Then
Set item = doc.GetFirstItem(fieldName)
If thisDataType = dataTypes(3) Then item.IsReaders = True
If thisDataType = dataTypes(4) Then item.IsAuthors = True
End If
End If
Call doc.Save(True, False)
Set doc = coll.GetNextDocument(doc)
Wend
End Sub '
Sorry for the long post but wasn't sure what is needed. First time posting for help but I'm scared I missed something opposite.
Francois