I am trying to figure out how to make sure data is entered into the InputBox at each stage (otherwise I want the message to pop-up and the entry to end). I have a MsgBox that pops up if nothing is entered but I want to add an option to have the Sub remain at the InputBox it is at so the user can still enter the data.
I've tried using vbRetryCancel and either the Retry will loop and then never actually cancel (and I have to force outlook to close to end the macro) or the Cancel will loop and it will never retry. If I could make it so the InputBox would not advance with "Ok" until data is entered or "cancel" was clicked that would work too but I would still need a MsgBox if nothing is entered to alert the user.
Sub Request_Tracking()
Dim objMsg As MailItem
Dim tasksource As String
Set objMsg = Application.CreateItem(olMailItem)
'requests input of the user with various options
tasksource = InputBox("Please select task receipt method:" & _
vbCrLf & vbTab & "1 - Phone call" & _
vbCrLf & vbTab & "2 - Email" & _
vbCrLf & vbTab & "3 - Instant Message" & _
vbCrLf & vbTab & "4 - Desk walk-up" & _
vbCrLf & vbTab & "5 - Miscellaneous", "Option Chooser")
'if response is blank then ends the task
If tasksource = vbNullString Then
MsgBox "Nothing was entered. Please re-enter your request.", vbOKOnly, "Error!"
Exit Sub
End If
Select Case tasksource
Case "1"
tasksource = "Phone call"
Case "2"
tasksource = "Email"
Case "3"
tasksource = "Instant Message"
Case "4"
tasksource = "Desk walk-up"
Case "5"
tasksource = "Miscellaneous"
Case Else
tasksource = tasksource
End Select
'various input boxes for data needed, if response is blank then ends the task without send
strName = InputBox("Requestor Name:")
If strName = vbNullString Then
MsgBox "Nothing was entered. Please reattempt your request.", vbOKOnly, "Error"
Exit Sub
End If
strCoreEvent = InputBox("Task Description:")
If strCoreEvent = vbNullString Then
MsgBox "Nothing was entered. Please reattempt your request.", vbOKOnly, "Error"
Exit Sub
End If
strUnitNum = InputBox("Number of units:")
If strUnitNum = vbNullString Then
MsgBox "Nothing was entered. Please reattempt your request.", vbOKOnly, "Error"
Exit Sub
End If
strTime = InputBox("Processing Time:")
If strTime = vbNullString Then
MsgBox "Nothing was entered. Please reattempt your request.", vbOKOnly, "Error"
Exit Sub
End If
'configures message being sent, sents to WFM box and formats the body font and various line breaks and then sends
With objMsg
.To = "[email protected]"
.Subject = "Request Received"
.HTMLBody = "<body style=font-size:11pt;font-family:Arial><b>For request tracking; please assign to me.</b>" & "<p>" & tasksource & " request from " & strName & ": " & strCoreEvent & "<br />Number of units: " & strUnitNum & "<br />Processing time: " & strTime & "</p></body>"
.Recipients.ResolveAll
.Send
End With
End Sub