Hi
Does anyone know how i can simplyfy my code which retrieves values from a document and then places them in a group document in an address book...i just think my code is too long and too repetitive.
Thanks
My code:
Sub SiteTeamAllStaffMembers
Dim s As New notessession
Dim UnicornDb As notesdatabase
Set UnicornDb = s.currentdatabase
Dim i As Integer
Dim p As Variant
Dim q As Variant
Dim teamview As NotesView
Dim itemField1 As NotesItem
Dim itemMembers1 As NotesItem
Dim itemMembers2 As NotesItem
Dim itemMembers3 As NotesItem
Set teamview = UnicornDb.GetView ("AllLiveTeamsByDivV" )
Set teamdoc = teamview.GetFirstDocument
While Not (teamdoc Is Nothing)
Groupp(1) = teamdoc.TeaSite(0) & " All Staff"
Dim pabview As NotesView
Set pabview = PABdb2.GetView ( "Groups" )
Set docNAB = pabview.getdocumentbykey(Groupp(1))
Set itemField1 = teamdoc.GetFirstItem("TeaSPO")
Set itemField2 = teamdoc.GetFirstItem("TeaPO")
Set itemField3 = teamdoc.GetFirstItem("TeaPSO")
Set itemField4 = teamdoc.GetFirstItem("TeaTPO")
Set itemField5 = teamdoc.GetFirstItem("TeaTempPO")
Set itemField6 = teamdoc.GetFirstItem("TeaSTA")
Set itemField7 = teamdoc.GetFirstItem("TeaOA")
Set itemField8 = teamdoc.GetFirstItem("DivTA")
Set itemField9 = teamdoc.GetFirstItem("TeaOtherStaff")
Set itemField10 = teamdoc.GetFirstItem("TeaTempAdmin")
Set itemMembers1 = docNAB.ReplaceItemValue("Members", "")
Set itemMembers2 =docNAB.ReplaceItemValue("Members", "")
Set itemMembers3 =docNAB.ReplaceItemValue("Members", "")
Set itemMembers4 =docNAB.ReplaceItemValue("Members", "")
Set itemMembers5 =docNAB.ReplaceItemValue("Members", "")
Set itemMembers6 =docNAB.ReplaceItemValue("Members", "")
Set itemMembers7 =docNAB.ReplaceItemValue("Members", "")
Set itemMembers8 =docNAB.ReplaceItemValue("Members", "")
Set itemMembers9 =docNAB.ReplaceItemValue("Members", "")
Set itemMembers10 =docNAB.ReplaceItemValue("Members", "")
' Set itemMembers2 = docNAB.GetFirstItem("members")
'+++++++++++++
If Not (itemField1 Is Nothing) Then
Forall v In itemField1.Values
If Not (itemMembers1 Is Nothing) Then
Call itemMembers1.AppendToTextList(v)
Call docNAB.Save(True, True)
End If
End Forall
End If
'+++++++++++++
If Not (itemField2 Is Nothing) Then
Forall v In itemField2.Values
If Not (itemMembers2 Is Nothing) Then
Call itemMembers2.AppendToTextList(v)
Call docNAB.Save(True, True)
End If
End Forall
End If
'+++++++++++++
If Not (itemField3 Is Nothing) Then
Forall v In itemField3.Values
If Not (itemMembers3 Is Nothing) Then
Call itemMembers3.AppendToTextList(v)
Call docNAB.Save(True, True)
End If
End Forall
End If
'+++++++++++++
If Not (itemField4 Is Nothing) Then
Forall v In itemField4.Values
If Not (itemMembers4 Is Nothing) Then
Call itemMembers4.AppendToTextList(v)
Call docNAB.Save(True, True)
End If
End Forall
End If
'+++++++++++++
If Not (itemField5 Is Nothing) Then
Forall v In itemField5.Values
If Not (itemMembers5 Is Nothing) Then
Call itemMembers5.AppendToTextList(v)
Call docNAB.Save(True, True)
End If
End Forall
End If
'+++++++++++++
If Not (itemField6 Is Nothing) Then
Forall v In itemField6.Values
If Not (itemMembers6 Is Nothing) Then
Call itemMembers6.AppendToTextList(v)
Call docNAB.Save(True, True)
End If
End Forall
End If
'+++++++++++++
If Not (itemField7 Is Nothing) Then
Forall v In itemField7.Values
If Not (itemMembers7 Is Nothing) Then
Call itemMembers7.AppendToTextList(v)
Call docNAB.Save(True, True)
End If
End Forall
End If
'+++++++++++++
If Not (itemField8 Is Nothing) Then
Forall v In itemField8.Values
If Not (itemMembers8 Is Nothing) Then
Call itemMembers8.AppendToTextList(v)
Call docNAB.Save(True, True)
End If
End Forall
End If
'+++++++++++++
If Not (itemField9 Is Nothing) Then
Forall v In itemField9.Values
If Not (itemMembers9 Is Nothing) Then
Call itemMembers9.AppendToTextList(v)
Call docNAB.Save(True, True)
End If
End Forall
End If
'+++++++++++++
If Not (itemField10 Is Nothing) Then
Forall v In itemField10.Values
If Not (itemMembers10 Is Nothing) Then
Call itemMembers10.AppendToTextList(v)
Call docNAB.Save(True, True)
End If
End Forall
End If
'+++++++++++++
Set teamdoc = teamview.GetNextDocument(teamdoc)
Wend
End Sub

Simplyfy code - Too Repetitive (Nadeem Shaikh 25.Jan.04)
. . 