Microsoft Access 2010 tutorial:Controls Part I


Controls Part I

V. Controls

In Microsoft Office Access 2010, there are a lot of controls, but in this section we select some controls that are frequently used. Those controls include Label, Text Box, Combo Box, List Box, Check Box, Command Button,  Option Button, Option Group, Image,  Subform/Subreport, and Chart. For each control mentioned above has its own icon. To see the icon of each control, look the figure below:

Access 2010 Controls  

V.1. Label

Label control is used to display information. To use it, you have to drag and drop it on the Design View form. To set caption, name, back color, fore color, border style, font size and so on, you can do them in the Property Sheet. To display the Property Sheet, you can Press F4 or click Properrt Sheet in Tools group of Design tab or hold down Alt+Enter.

Access Label control

V.2. Text Box

Text Box control is used to type text in. For example, type user name and password in User Name and Password Text Boxes.

Access Text Box control

V.3. Combo Box

Combo Box control is used to type or select any items in. For example, select M or F in Sex Combo Box.

Microsoft Office Access 2007 Combo Box

In default, when you drag and drop a Combo Box control on a form, the Combo Box does not contain values. To add values or items to the Combo Box, there are two ways as the following:

1. Add values to a Combo Box by using Value List
When you want to add values to a Combo Box by typing values into the Row Source or by using AddItem method in theVBA Code,  you need to assign Value List to Row Source Type  property. To do this task, you have to follow the steps below:

- Click Combo Box control you want to add values

- Press F4 if the Property Sheet is displayed

- Click  Data tab

- Select Value List in front of  the Row Source Type property

- Type values in front of Row Source property. For example, type F and M separate by semicolon(;).

Access Combo Box control with its properties

- Or type the following VBA code in Form_Load event procedure:

Private Sub Form_Load()

     Combo0.RowSourceType = "Value List"
     Combo0.AddItem "F"
     Combo0.AddItem "M"

End Sub

2. Add values to a Combo Box by using Table/Query

Once you want to add values to a Combo Box by retrieving values from a table or query, you need to assign Table/Query to Row Source Type property. To do this task, you have to follow the steps below:

- Click Combo Box control you want to add values

- Press F4 if the Property Sheet is not displayed

- Click Data tab

- Select Table/Query in front of Row Source Type property

- Type SQL statement in front of Row Source property

For example, select CategoryID field of TblCategory into CboCategory(Combo Box's name). Look the figure below maybe easier to understand.

Access add values to Combo Box control  

- Or type the following VBA code in Form_Load event procedure:

Private Sub Form_Load()

   Combo0.RowSourceType = "Table/Query"
   Combo0.RowSource = "Select CategoryID from TblCategory"

End Sub

V.4. List Box

Using List Box is similar to using Combo Box because they both are used to display a list of values or choices. However, they are different. List Box doesn't have drop-down arrow while the Combo Box contains. One more different point is that you can type data in the Combo Box while you cannot do this in the List Box. For assigning values into the List Box, you can follow the both steps of assigning values into Combo Box above.

Access List Box control


Comments




This website intents to provide free and high quality tutorials, examples, exercises and solutions, questions and answers of programming and scripting languages:
C, C++, C#, Java, VB.NET, Python, VBA,PHP & Mysql, SQL, JSP, ASP.NET,HTML, CSS, JQuery, JavaScript and other applications such as MS Excel, MS Access, and MS Word. However, we don't guarantee all things of the web are accurate. If you find any error, please report it then we will take actions to correct it as soon as possible.