Developer sometimes can be tricked how to load value from tables in order to be more easier for them to be selected the value from the dropdown list. By going through this scenario, the programmers must create a table in order to load this data into Combobox in order to prevent adding more job in the VBA programming. They can only add data into table and it will be populated into Combobox automatically.
In order to work with this tutorial, it needs to create one table and one form to store the Combobox control.
Create Table Users To Store UserName in the Table
Going to Create Table then select Table Design
After that create some field names such as Userid, Username, Password, Gender, Role as image below then Save as user_info and after that click on Ok
Microsoft Access will promptly ask the question to get Primary Key for id, so you just click on No
Going back to your Table on the left panel, then select on the user_info table to add some data or record into the table
Create Form Design to Store Combobox Control
Within Create Tab, select More Forms then Modal Dialogue then in the control panel in Design Tab, please select Combobox control to drag into Form Design
After dragging into Form Design then select Cancel, please go to property sheet and rename this Combobox as cboUsername
To write VBA programming language, please right click on Form Design then select Build Event after that Code Builder. On the Detail event, please select Form Load
In Form Load, please copy this code below:
Private Sub Form_Load() Me.cboUsername.RowSourceType = "Table/Query" Me.cboUsername.RowSource = "select Username from user_info" End Sub
See the result below after you have used the code the above