On Error Goto processerror
Dim ws As New NotesUIWorkspace
Dim session As New NotesSession
Dim uidoc As NotesUIDocument
Dim currdoc As NotesDocument
Dim array() As String
Set uidoc = ws.CurrentDocument
Set db = session.CurrentDatabase
Set currdoc = uidoc.Document
BUname= uidoc.Document.BUname
Subbu = uidoc.Document.Subbu
Cyear = uidoc.Document.Pyear
method = uidoc.Document.method1
topic = uidoc.Document.topic
product= uidoc.Document.product
market= uidoc.Document.market
project= uidoc.Document.Ptype
Competitor= uidoc.Document.Compet
'Creating view selection formula based on the selection of
multivalue field.
temp = ""
If BUname(0) > "None" Then
Forall u In BUname
If temp = "" Then
temp =|BName="|+u+|"|
Else
temp = temp + ||| BName="|+u+|"|
End If
End Forall
array(0) = "(" + temp + ")"
End If
temp = ""
If Subbu(0) > "None" Then
Forall u1 In Subbu
If temp = "" Then
temp = |SubBUname="|+u1+|"|
Else
temp = temp + ||| SubBUname="|+u1+|"|
End If
End Forall
array(1) = "(" + temp + ")"
End If
temp = ""
If Cyear(0) > "None" Then
Forall w In Cyear
If temp = "" Then
temp = |year="|+w+|"|
Else
temp = temp + ||| year="|+w+|"|
End If
End Forall
array(2) = "(" + temp + ")"
End If
temp = ""
If method(0) > "None" Then
Forall x1 In method
If temp = "" Then
temp = |method="|+x1+|"|
Else
temp = temp + ||| method="|+x1+|"|
End If
End Forall
array(3) = "(" + temp + ")"
End If
temp = ""
If product(0) > "None" Then
Forall x2 In product
If temp = "" Then
temp = |product1="|+x2+|"|
Else
temp = temp + ||| product1="|+x2+|"|
End If
End Forall
array(4) = "(" + temp + ")"
End If
temp = ""
If topic(0) > "None" Then
Forall x3 In topic
If temp = "" Then
temp = |topic1="|+x3+|"|
Else
temp = temp + ||| topic1="|+x3+|"|
End If
End Forall
array(5) = "(" + temp + ")"
End If
temp = ""
If market(0) > "None" Then
Forall x4 In market
If temp = "" Then
temp = |market="|+x4+|"|
Else
temp = temp + ||| market="|+x4+|"|
End If
End Forall
array(6) = "(" + temp + ")"
End If
temp = ""
If project(0) > "None" Then
Forall x5 In project
If temp = "" Then
temp = |Ptype="|+x5+|"|
Else
temp = temp + ||| Ptype ="|+x5+|"|
End If
End Forall
array(7) = "(" + temp + ")"
End If
temp = ""
If Competitor(0) > "None" Then
Forall x3 In Competitor
If temp = "" Then
temp = |Competitor="|+x3+|"|
Else
temp = temp + ||| Competitor="|+x3+|"|
End If
End Forall
array(8) = "(" + temp + ")"
End If
temp = ""
'remove null values from array
result = Fulltrim(array)
value = Implode(result,"&")
Dim uiview As NotesUIView
Dim views As NotesView
Dim formula As String
Set views = db.GetView("searchv")
formula="SELECT (Form ='GMPI Market')&"+value
views.SelectionFormula = formula
'Close the search form and open the searc frameset wich contain
search document.
Call uidoc.Close
Call ws.OpenFrameSet("search")
processerror:
Print "ERROR " & (Str$(Err) & " : "&Error$(Err) & " on line
---->"&Str$(Erl)) & " " &fullfile
Exit Sub