VB code to add items to a Combo Box

  • Thread starter Thread starter RobinF
  • Start date Start date
Robin,

If your combo box gets its data from a table, then you need to add data to
the table, then requery the combo:
CurrentDb.Execute "INSERT INTO tblTable (Field1, Field2) VALUES (1,2),
dbFailOnError
Me.cboMyCombo.Requery

If your combo gets its data from a list you've provided, you can add to that
list at runtime:
Me.cboMyCombo.RowSource = Me.cboMyCombo.RowSource & ";" & strSomeText

....but, the latter example will only be temporary. It won't be there next
time you open the form. To make it stick, you need to open the form in
design view, save the additional data to the combo, then save and close the
form.

Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Back
Top