Access 2003 Combo Box Updating via VB Code

By carterlangley ·
Hey there guys,

got a combo box on getting its values from a table. if value is not in the table then the user enters the value in a textbox and clicks a command button to enter the new value into the table. now i need to be able to refresh/requery the combo box so the new value appears there without closing and reopening the form. Please help with this, been racking my brains for the past three days and have now spent far to much time on one little problem.

Please give me an example of code so I can have a look and learn.

This conversation is currently closed to new comments.

Thread display: Collapse - | Expand +

All Answers

Collapse -

try this...

by jmperez_uplb96 In reply to Access 2003 Combo Box Upd ...

when the user clicks the command button to save, add the requery statement after you perform the save function (i guess you used either the database execute SQL statement or Docmd), assuming you have the ucList combo box control, you may code it like:

Private Sub ucSave_Click()
On Error GoTo errorHandler

DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
Exit Sub

MsgBox Err.Description, vbOKOnly + vbInformation, C_APPLICATION_LABEL

Hope this helps.

Collapse -

Combo Box Requery

by carterlangley In reply to try this...

Everything is done using SQL statements. connecting through ADO. Normal combo box unbound. I have tried to issue a requery statement after the recordset.update statement but that did not do it.


code to populate the table


What should I add after the update statement to requery the combo box and show the new record? The requery statement for a control on the form does not seem to work. I have seen this done before but did not make a copy of the code so now am sitting with my finger up my bum!!!

Collapse -

I use a little function

by aguila_bel_ami In reply to Access 2003 Combo Box Upd ...

In this case I put it in a click event to refresh many combos at once,
but you can make it With a parameters to reuse it through out your app,


Private Sub btnRefresh_Click()
Dim varData As Variant
Dim i As Integer
varData = Array("Combo28", "ExpenseCategoryID", "Combo37", "Combo39", "Combo48", "Combo50", "Combo62")
For i = 0 To 6
Set ctlCombo = Me(varData(i))
Next i
End Sub

Related Discussions

Related Forums