How to populate a ComboBox with a Recordset using VBA

前端 未结 6 781
星月不相逢
星月不相逢 2021-02-15 13:34

There is some literature available at expert\'s exchange and at teck republic about using the combobox.recordset property to populate a combobox in an Access form.

The

6条回答
  •  星月不相逢
    2021-02-15 13:59

    To set a control that accepts a rowsource to a recordset you do the following:

    Set recordset = currentDb.OpenRecordset("SELECT * FROM TABLE", dbOpenSnapshot)
    Set control.recordset = recordset
    

    Works with DAO Recordsets for sure, I haven't tried ADO recordsets because I don't have any real reason to use them.

    When done this way, a simple requery will not work to refresh the data, you must do a repeat of the set statement.

提交回复
热议问题