INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Misc

Alternative to F9 to requery combo boxes by markphsd
Posted: 20 Nov 06

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
  
  Exit Sub
eh:
  
 ' insert your own error routine here.
  
  
End Sub

Back to Microsoft: Access Modules (VBA Coding) FAQ Index
Back to Microsoft: Access Modules (VBA Coding) Forum

My Archive

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close