VBA & Macro Problems

How to Populate an Excel VBA ComboBox from an ADODB Recordset

Khadija KhanKhadija Khan Oct 23, 2026 871 views

Question details

The user needs to populate a VBA ComboBox with data fetched from an ADODB Recordset, but lacks a direct binding property.

Populating an Excel VBA ComboBox from an ADODB Recordset
Product
Excel
Device & OS
not provided
Scenario
Developing Excel VBA macros or userforms that require pulling dynamic data from an external database using ADODB.
Observed behavior
Excel VBA ComboBox controls do not natively support direct ADODB Recordset binding because they lack a Recordset property.
Before you start

Ensure you have enabled the 'Microsoft ActiveX Data Objects Library' reference in your VBA Editor (Tools > References) so that your ADODB objects function properly.

Solution 1Recommended

Use the ComboBox Column Property (Direct Method)

This is the most efficient and straightforward method. It uses the GetRows method to assign data directly to the Column property without needing to transpose it.

The ADODB Recordset's GetRows method naturally returns data in a two-dimensional array structured as (Columns, Rows). Because the ComboBox's Column property expects data in exactly this orientation, you can assign the array directly.

1
Open VBA Editor

Press Alt + F11 to open the VBA Editor, and navigate to the code module for your UserForm.

2
Execute the ADODB Query

Ensure your connection string is active and open the recordset containing the desired database query.

3
Assign Data to the Column Property

Use the GetRows method on your recordset to push the target field into the ComboBox. Write the code: Combo.Column = RstComboPopulating.GetRows(Fields:=FieldName).

4
Close the Recordset

Close the recordset to free up system memory by adding: RstComboPopulating.Close followed by Set RstComboPopulating = Nothing.

Use the ComboBox Column Property (Direct Method)
Performance Tip: Using GetRows directly into the Column property is significantly faster than looping through the recordset with AddItem, especially for large datasets.
Free Microsoft Office alternative

Looking for a Lightweight and Compatible Office Suite?

If you frequently manage complex spreadsheets, analyze large datasets, or handle legacy macro files, WPS Office offers a fast, familiar, and highly compatible alternative. It's designed to streamline your workflow without the heavy system requirements.

  1. 1. Visit the WPS Website: Go to the official WPS Office website to find the free installer.
  2. 2. Download and Install: Run the lightweight installer package and follow the on-screen instructions.
  3. 3. Open Your Spreadsheets: Launch WPS Spreadsheets and open your existing documents to start working immediately.
Highly compatible with Microsoft Excel (.xlsx, .xls, .xlsm, .csv) formatsFamiliar user interface ensuring seamless migration with zero learning curveLightweight architecture that runs smoothly on almost all Windows PCsFree built-in PDF editing, document conversion, and data analysis tools
microsoft office alternative - wps office

Frequently Asked Questions

Why can't I bind the ADODB recordset directly to the VBA ComboBox?

Unlike data controls in MS Access or VB6, standard Excel VBA ComboBoxes lack a 'DataSource' or 'Recordset' property for native data binding. You must manually extract the data, typically using the GetRows method, and assign it to the control.

What happens if my ADODB Recordset is empty when calling GetRows?

If the recordset is empty, calling GetRows will throw a run-time error (such as Error 3021: Either BOF or EOF is True). You should always verify that 'RstComboPopulating.EOF' is False before attempting to fetch rows.

Can I limit the number of records populated in the ComboBox?

Yes. The GetRows method accepts an optional 'Rows' parameter. For example, using 'GetRows(50)' will return only the first 50 records from your active ADODB query.

Do I need to loop through the recordset to add items?

While you can loop through records using 'ComboBox.AddItem', fetching the data en masse via 'GetRows' and applying it to the Column or List property is much faster and reduces code complexity.