I am trying to create a db search agent using lotus script and I am trying to pass values from three prompt boxes, one for the name of the field, old value and the new value I want to insert into the field. This is all pretty straight forward. If I do a search just by the form or hard code the name the Field and the old value it also works fine. But I want to be able the select any field and old value. I don’t want to just search by the form name for there are a few thousand documents using that form. Any suggestions?Here is the code
Dim session As New NotesSession
Dim db As NotesDatabase
Dim collection As NotesDocumentCollection
Dim doc As NotesDocument
Set db = session.CurrentDatabase
Dim count As Integer
Dim newValue As String
Dim oldValue As String
Field1 = Inputbox("What is the name of the field? ")
oldvalue = Inputbox("What is the old Value? ")
newValue = Inputbox("What is the new Value? ")
'searchFormula$ = {Form = "TA" & Field1= oldvalue}
'This is a try to use the information in the Inputbox but doesn't seem to work!!!!
searchFormula$ = {Form = "TA" & Field_2 = "oldvalue"}
'This works but I have to hard code the field and its value!!!
count = 0
Set collection = db.Search(searchFormula$,Nothing,0)
Set doc = collection.GetFirstDocument()
While Not(doc Is Nothing)
count = count +1
If doc.field_2(0) = oldvalue Then
Call doc.ReplaceItemValue("Field_2", newValue)
End If
Call doc.Save( True, False )
Set doc = collection.GetNextDocument(doc)
Wend
Messagebox count, MB_OK, "Number of docs changed! "
End Sub