Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Input box cancel question..

Status
Not open for further replies.

jmorlock

Programmer
Apr 25, 2003
46
US
I have the following input box in my form prompting for a name. If the user presses the cancel button how to i catch that? I want to close the form once he clicks the cancel button.

prompt = "Please enter the Client Name."
name = InputBox(prompt, "Survey", "Enter name here.")
 
hi,

try this:

'**********begin code example********

Dim prompt As String
Dim Name As String

prompt = "Please enter the Client Name."
Name = InputBox(prompt, "Survey", "Enter name here.")
If Name = Empty Then
DoCmd.Close acForm, Me.Name
End If

'***********end code example************

HTH

Have A Great Day!!!, [bigglasses]

Nathan
Senior Test Lead
 
I've not tested it in detail, but isn't it just blank or null? You could test it out by displaying a msgbox with the value of name just to see it displayed.

Let me know how you get on.
jr
 
Yeah if you hit the cancel button the inputbox will return either "" or null value. Thanks for the help
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top