F9 is the short cut to requery combo and listboxes on forms, but it means you have to tell your users to use it, and they have to remeber to use it.
This is an alternative that you can use on all of your forms when you modify the data in a combo box. Rather than using a requery even for each combo box, it will find any combo boxes in the main forms of you application that are open. I don't have a sub form requery code written but i'm sure i'll get around to it soon enough:
Place this in a module and call it whenever you modify the contents of combo or list boxes.
Public Sub RefreshComboBoxes()
On Error GoTo eh:
Dim frm As Form
Dim obj As Object
Dim oCtl As Control
Dim sbfrm As Form
Dim oCtlSub As Control
For Each obj In CurrentProject.AllForms
If CurrentProject.AllForms(obj.Name).IsLoaded Then
Set frm = Forms(obj.Name)
For Each oCtl In frm
Select Case oCtl.ControlType
Case acComboBox, acListBox
oCtl.Requery
End Select
Next
End If
Next obj
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.