Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Populate Combo box in vba

Status
Not open for further replies.

gcole

Programmer
Aug 2, 2000
390
US
I need to populate my combo box in vba. What is the code to make addnew available? The name of my combo box is 'cmb_Mgr'.
 
Use the On Not In List event to add records through a combo box.
 
Hello gcole,

What will be your Row Source Type, Value List, Table/Query or Field List? It is easy enough to set the Row Source value in vba code.

cmb_Mgr.RowSource = "Whatever"

Regards,
gkprogrammer
 
I want to populate it when my form opens. Before the user sees it. I was using a query, but I need some additional items in the list.
 
I know that I can set the rowsource. The problem is I don't get an addnew option with my cmb_Mgr list.
 
I wanted to answer this thread, incase someone else needs it. Here is my solution:
In the On Open event for my form I populated the ComboBox:
My values were in a query that I made into a table and opened:
Do Until rstMgr.EOF
sCmbValues = sCmbValues & ";'" & stMgr.Fields "EmpName") & "'"
rstMgr.MoveNext
Loop

sCmbValues = sCmbValues & "'All Groups'"

Me.cmb_UM.RowSource = sCmbValues

The string to populate looked like this: "'All Groups'";"'Group 1'" ....

I hope it is helpful

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top