Refreshing data resource for combo box

P

Pawel

Hello,

I have an combo box with a query as a data source. Query
takes data from separate table. I am trying to dinamically
add data to combo box.

Here is the code:

Private Sub Model_NotInList(NewData As String, Response As
Integer)

Dim ctl As Control

Dim dbs As Database
Dim rst As Recordset

Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("Model", dbOpenDynaset)

rst.AddNew
rst!Model = NewData

rst.Update

rst.Close
dbs.Close

End Sub

So the newly entered item was added to the table. How can
I refresh combo box so on its list there will be new item?

With above code everything what I am able to achieve is
error message that I should pick up item from the list.

Thank you,

Pawel
 
M

Mike M.T.

Check the solutions database (it's on your Microsoft Office cd).
In the "Work with combo boxes, list boxes, subforms, and reports" category
you will find the "Add new record to a list" example. Study the code behind
and adapt to your needs.

Important: The query used as datasource must allow updates to the table.
 

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

Top