Have you tried it? If user presses cancel button (How could I use the cancel button in an Input Box to cancle out of the form and close?) it will work. Go ahead and give it a try. If you are complaining that it ends the program then replace end with unload me, or if you are stating that they click on ok with a default there then just remove the default. Go ahead and give it a try, it may help you understand how to accomplish what you want
If you want to UNLOAD the form, after the user cancels the InputBox, you have to do Unload Me or whatever you do to cancel the form. If you have code in a cancel button on your form, try this:
Private Sub Form_Load()
'......
TheValue = InputBox("Prompt", "Title", "Default"
If TheValue = "" Then
Call CancelButton_click
exit sub
End If
ErrorHandler:
If Err.Number = 3421 Then
MsgBox "You have entered a class number that is not correct. Please re-enter a correct class number", vbCritical
Resume ContinueHere
Else
MsgBox Err.Number & ": " & Err.Description 'this Catches other errors
Resume ContinueHere
End If
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.