Ark68
Well-known Member
- Joined
- Mar 23, 2004
- Messages
- 4,616
- Office Version
- 365
- 2016
- Platform
- Windows
I am working with this code for an inputbox. But I'm not sure how to trap user entry outside of the allowable values of 1-7. With an invalid error, keep prompting the user to enter a value until an allowable one is selected, or they hit CANCEL.
I tried a "Do/Loop Until", but I ran into a snag when checking the value entered. Since the allowable values are entered as text, I couldn't figure out how to isolate a text value of 1 to 7 from just a random string.
Suggestions?
Code:
ui1 = InputBox("Select: " & Chr(13) & _
"(1) Diamonds" & Chr(13) & _
"(2) Fields" & Chr(13) & _
"(3) Courts" & Chr(13) & _
"(4) Trails" & Chr(13) & _
"(5) Passive" & Chr(13) & _
"(6) ALL", "Setup Sheet Compilation", "6")
If ui1 = "" Then
Exit Sub
ElseIf ui1 = "1" Then
pop_Dsvc svcnum
ElseIf ui1 = "2" Then
pop_Fsvc svcnum
ElseIf ui1 = "3" Then
pop_Csvc svcnum
ElseIf ui1 = "4" Then
pop_Tsvc svcnum
ElseIf ui1 = "5" Then
pop_Psvc svcnum
ElseIf ui1 = "6" Then
pop_Dsvc svcnum
pop_Fsvc svcnum
pop_Csvc svcnum
pop_Tsvc svcnum
pop_Psvc svcnum
Else
MsgBox "Error"
End If
End If
I tried a "Do/Loop Until", but I ran into a snag when checking the value entered. Since the allowable values are entered as text, I couldn't figure out how to isolate a text value of 1 to 7 from just a random string.
Code:
Do
ui1 = InputBox("Select: " & Chr(13) & _
"(1) Diamonds" & Chr(13) & _
"(2) Fields" & Chr(13) & _
"(3) Courts" & Chr(13) & _
"(4) Trails" & Chr(13) & _
"(5) Passive" & Chr(13) & _
"(6) ALL", "Setup Sheet Compilation", "6")
Loop Until cDbl(ui1) > 0 and cDbl(ui1) < 7
If ui1 = "" Then
Exit Sub
ElseIf ui1 = "1" Then
pop_Dsvc svcnum
ElseIf ui1 = "2" Then
pop_Fsvc svcnum
ElseIf ui1 = "3" Then
pop_Csvc svcnum
ElseIf ui1 = "4" Then
pop_Tsvc svcnum
ElseIf ui1 = "5" Then
pop_Psvc svcnum
ElseIf ui1 = "6" Then
pop_Dsvc svcnum
pop_Fsvc svcnum
pop_Csvc svcnum
pop_Tsvc svcnum
pop_Psvc svcnum
Else
MsgBox "Error"
End If
End If
Suggestions?