Drop-down list (1)

In this example, I will discuss how to add a drop-down list to a form. Let me start with what I already made.

I have drawn a shape (1) in the department worksheet and when I click on the this, it opens a form (2) (frmData) with a name field (txtName) (3), a button “add” (cmdAdd) (4) to add data into the table in the worksheet “department” (5), and a button “Close” (cmdClose) (6) to close the form.

les12_image001_en

You should already be able to create this, but let me repeat the process anyway.

Right-click the shape you have drawn and select “Assign Macro”. In the macro window (A) that appears, you give this macro a name (Name_Click), and click the “New” button. In the VBA window, the beginning and end of the subroutine is completed. So the only thing you have to type in between is the code for frmData.Show (B). When we click on the shape, this will open the form as this has now become a button.

les12_image002_en

In the form (frmData), I created a text box (txtName), an “add” button (cmdAdd) and a close button (cmdClose).

les12_image003_en
Now we can add a drop-down list. Select the control “Combo” (2) in the toolbox window and click and drag it in the form (3) until the desired size is reached.
I give the Name ‘cboDepartment” to this object (4).

les12_image004_en
In the next lesson we will add the code.

Awesome!
You've completed Lesson 12
START NEXT LESSON