How to add BOTH static values and records from a table as list items to a combo box in VBA

Luca Guarro

I have a combo box that gets its list items from a query. But in addition to these items, I need one static option that will be there in all cases.

I tried doing this in the naive way:

Private Sub Form_Open(Cancel As Integer)
   Set rst = CurrentDb.OpenRecordset("SELECT ESDNodes.Description, ESDNodes.Sort FROM ESDNodes WHERE (((ESDNodes.parentID) =" & parentID & ")) ORDER BY ESDNodes.Sort")
   Set nextSiblingSelect.Recordset = rst
   nextSiblingSelect.AddItem Item:="Make Last", Index:=0
End Sub

but end up with this run-time error

The RowSourceType property must be set to 'Value List' to use this method.

which I half-expected.

Is there any trick around this? I suppose I could add a dummy record to my table set and change the query but that would be rather ugly and I would not prefer it.

June7

Try a UNION query as the combobox RowSource. Maybe like:

SELECT Description, Sort FROM ESDNodes UNION SELECT "Make Last", 0 FROM ESDNodes ORDER BY Sort;

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How to add data table items in a combo box?

From Dev

How to add items from combo box into array

From Dev

Extjs how to remove and undo list items from extjs combo box

From Dev

VBA Add combo box values together

From Dev

how to add value from one combo box to another combo box

From Dev

How to add a list of files into a combo box?

From Dev

How to add a list of files into a combo box?

From Dev

How to add scroollbar to combo box items in c#

From Dev

Xpages add values into Combo Box

From Dev

How to send these items in the combo box

From Dev

How can I automatically sum values that I add from a combo box to a text area?

From Dev

Unselectable items in a Combo Box in an Excel VBA

From Dev

How to pass values from an array to a drop down list in a certain cell (not combo list) in excel VBA

From Dev

list first and last name in combo box from a sql table

From Dev

Adding items to combo box in a table in netbeans

From Dev

Adding items to combo box in a table in netbeans

From Dev

VBA Insert two list box values into a table

From Dev

Assigning values to Combo box in excel VBA

From Dev

Assigning values to Combo box in excel VBA

From Dev

How can I add a value from a combo box into a text area?

From Dev

Excel VBA adding items to combo box without repeated items

From Dev

Excel VBA adding items to combo box without repeated items

From Dev

How to add a text box + combo box

From Dev

Excel VBA: Looping through a combo box's items from another user form

From Dev

How to list combo box data based on another combo box entry

From Dev

How to Open Drop down (combo items) of Combo Box on KeyDown Event?

From Dev

How to Open Drop down (combo items) of Combo Box on KeyDown Event?

From Dev

Passing Cell Values into a combo box list

From Dev

Populating a combo box with values from an enum

Related Related

  1. 1

    How to add data table items in a combo box?

  2. 2

    How to add items from combo box into array

  3. 3

    Extjs how to remove and undo list items from extjs combo box

  4. 4

    VBA Add combo box values together

  5. 5

    how to add value from one combo box to another combo box

  6. 6

    How to add a list of files into a combo box?

  7. 7

    How to add a list of files into a combo box?

  8. 8

    How to add scroollbar to combo box items in c#

  9. 9

    Xpages add values into Combo Box

  10. 10

    How to send these items in the combo box

  11. 11

    How can I automatically sum values that I add from a combo box to a text area?

  12. 12

    Unselectable items in a Combo Box in an Excel VBA

  13. 13

    How to pass values from an array to a drop down list in a certain cell (not combo list) in excel VBA

  14. 14

    list first and last name in combo box from a sql table

  15. 15

    Adding items to combo box in a table in netbeans

  16. 16

    Adding items to combo box in a table in netbeans

  17. 17

    VBA Insert two list box values into a table

  18. 18

    Assigning values to Combo box in excel VBA

  19. 19

    Assigning values to Combo box in excel VBA

  20. 20

    How can I add a value from a combo box into a text area?

  21. 21

    Excel VBA adding items to combo box without repeated items

  22. 22

    Excel VBA adding items to combo box without repeated items

  23. 23

    How to add a text box + combo box

  24. 24

    Excel VBA: Looping through a combo box's items from another user form

  25. 25

    How to list combo box data based on another combo box entry

  26. 26

    How to Open Drop down (combo items) of Combo Box on KeyDown Event?

  27. 27

    How to Open Drop down (combo items) of Combo Box on KeyDown Event?

  28. 28

    Passing Cell Values into a combo box list

  29. 29

    Populating a combo box with values from an enum

HotTag

Archive