The navigation form appears in the same list as my other forms, I am using it as a navigation form.. I do have navigation buttons on this form, though.
Code:
Private Sub cmdAddRep_Click()
Dim olApp As Outlook.Application
Dim myItem As Outlook.TaskItem
Dim myDelegate As Outlook.Recipient
Dim strName As String, strEmail As String, iPos As Integer, i As Integer
Dim strFirst As String, strLast As String, iPos2 As Integer
Dim strAccess As String, arrAccess(3) As String, strBadge As String
Dim intConfirm As Integer, strAccessLevel As String
strName = InputBox("Please enter the persons name")
If (strName = "") Then Exit Sub
Set olApp = GetOutlookApp()
Set myItem = olApp.CreateItem(olTaskItem)
Set myDelegate = myItem.Recipients.Add(strName)
myDelegate.Resolve
If (myDelegate.Resolved = True) Then
strName = myDelegate.Name
iPos = InStr(1, strName, ", ")
strFirst = Mid(strName, iPos + 2)
iPos2 = InStr(strFirst, "(")
strLast = Left(strName, iPos - 1)
If (iPos2 > 0) Then
strFirst = Mid(strFirst, 1, InStr(1, strFirst, "(") - 2)
End If
strLast = Left(strName, iPos - 1)
strName = Trim(strFirst & " " & strLast)
For i = 0 To Form_Management.lstUsers.ListCount - 1
If (Form_Management.lstUsers.ItemData(i) = strName) Then
intConfirm = MsgBox("That user is already in the list. If you want to continue, this users existing entry in the security database will be updated to the new values. Would you like to continue?", vbYesNo + vbExclamation)
If (intConfirm = vbNo) Then
GoTo NotAdded
Else
strBadge = Form_Management.lstUsers.Column(1, i)
End If
End If
Next i
strEmail = myDelegate.Address
strEmail = Mid(strEmail, InStrRev(strEmail, "=") + 1) & "@XXXXX.com"
strAccessLevel = "Attendee (temp)"
AddToDB strName, strBadge, strEmail, strAccessLevel
Else
MsgBox "Could not find user '" & strName & "' in the address book. Please confirm spelling and try again. You may also enter the representative using their first initial and last name as it appears in their email address (ie. JDoe).", vbInformation
Exit Sub
End If
Form_Management.lstUsers.RowSource = ""
LoadRepresentatives Form_Management.lstUsers
Form_EventEntry.lstAttendees.RowSource = ""
For i = 0 To Form_Management.lstUsers.ListCount - 1
If ((Form_Management.lstUsers.Column(3, i) = "Scheduler") Or (Left(Form_Management.lstUsers.Column(3, i), 8) = "Attendee")) Then
Form_EventEntry.lstAttendees.AddItem Form_Management.lstUsers.ItemData(i)
End If
Next i
NotAdded:
Set myDelegate = Nothing
Set myItem = Nothing
Set olApp = Nothing
End Sub