Home

The Input Box

 

Introduction

 

Although most of the user's data entry will be performed on fields positioned on a form, you can display a special form to the user and expect a value. This form (actually a dialog box) is called an input box. To support this, Microsoft Access provides a function called InputBox and its basic syntax is:

InputBox(prompt)

The argument passed to the function is a message that would be displayed to the user. When the input box comes up, a form with a message and a text box would display to the user.

To display an input box to the user, place a control, such as a Button, to a form. Then, access the Properties window for the control. In the Properties window, use an appropriate field, such as On Click from the Events tab, and assign the function to the field. An example would be:

=InputBox("Enter the Radius of the Circle")

When the user clicks the button, an input box would display:

When an input box comes up, it does not display a caption in the title bar. If you want, you can display a title of your choice. To do this, pass a second argument to the InputBox() function. Here is an example:

=InputBox("Enter the Radius of the Circle","Geometric Figures")

This would produce:

When an input box comes up and you present a request, the user may not know what type of value you are expecting. To guide the user, you can provide a sample or default value. This value would display in the text box and it would be selected so the user can type to replace it.

To provide a default value to the input box, you can pass a third argument to the InputBox() function. Here is an example:

=InputBox("Enter the Radius of the Circle","Geometric Figures",10.5)

When the input box is called from this function, it would display as follows:

 

Home Copyright © 2008-2012 FunctionX