Results 1 to 7 of 7
  1. #1
    djclntn is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Feb 2011
    Posts
    476

    What is the code for requerying a Combo Box?

    I Goggled "how to refresh combobox in access" & I found this code:

    Private Sub Category_DblClick(Cancel As Integer)

    'Open code table
    DoCmd.OpenForm "CategoryCodes", acNormal, , , , acDialog
    Form_Suppliers!Category.Requery

    End Sub

    So. I implented this code into my Form. My Combo Box is a list of 4-CostomerID & how many Vehicles purchased (including those custmoers who have yet to purchased a vehicle). When I assign a customer to a vehicle in my Combo Box I want to see how many 'Vehicles' per customer after i imput a customer on my Forrm. To avoid having to hit Refressh & going to Record 1 there is a way i can Refresh/Requery my Combo Box unon going to the next Record, Right?

    For 'Table' I used the Forms' name?

    Here's the code I tried, but doesn't work

    Private Sub Combo53_DblClick(Cancel As Integer)


    'Open code Vehicles SUMS_Customers
    DoCmd.OpenForm "Combo53", acNormal, , , , acDialog
    Form_Vehicles SUMS_Customers!Combo53.Requery

    End Sub

  2. #2
    Missinglinq's Avatar
    Missinglinq is online now VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    To be honest, your stated scenario is murky, to say the least, and I have no idea what your code is supposed to be doing! You appear to be opening a Form named Combo53, which, I assume, is actually the name of your Combobox! If your object is to Requery a Combobox named Combo53, each time you move to a New/Different Record, try:

    Code:
    Private Sub Form_Current()
     Me.Combo53.Requery
    End Sub


    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  3. #3
    djclntn is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Feb 2011
    Posts
    476
    Ling,

    Where do I put the code, in AfterUpdate or On Enter...?

  4. #4
    Missinglinq's Avatar
    Missinglinq is online now VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    You put it in the Form_Current event, just as I posted it.

    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  5. #5
    djclntn is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Feb 2011
    Posts
    476
    No luck lin, I did exactly what you said, Close the Form, reopened the Form. When I tested my Combo Box & chose a customer that has 1-vehicle, clicked on their name for a second vehicle. when i went to a diffgerent Record, pulled down my customers combo box the customers who now brought 2-vehicles is still showing "1" in the combo box (list)

    I'll get back at this tomorrow...thanks

  6. #6
    djclntn is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Feb 2011
    Posts
    476
    Ling,

    I did what youi had instructed me to go on the Form Property, on the Event Tab & in the "On Current" type in the code: Me.Combo78.Requery. the Combo Box is named, 'ComboBox78'. I save, close the Form, reopen the Form, put in a customer in a Record, but the ComboBox doesn't update when I go to another Record. Ling, could the ComboBox not requerying/updating because i'm not going on a "New Record?" is that my hang-up?

  7. #7
    Missinglinq's Avatar
    Missinglinq is online now VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    Quote Originally Posted by djclntn View Post

    ...on the Form Property, on the Event Tab & in the "On Current" type in the code: Me.Combo78.Requery...
    If you're saying that you went to Property Pane for the Form, went the Events Tab and then, in the box for the OnCurrent event, typed in

    Me.Combo78.Requery

    that won't work! The code I gave you
    Code:
    Private Sub Form_Current()
     Me.Combo53.Requery
    End Sub


    has to appear, just like that, in the Code Module for your Form. You cannot simply enter it into the OnCurrent Property box!

    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 6
    Last Post: 10-15-2012, 01:49 PM
  2. Replies: 1
    Last Post: 08-09-2012, 04:19 PM
  3. Search Box Requerying Subform problem
    By cbh35711 in forum Access
    Replies: 1
    Last Post: 03-30-2012, 09:37 AM
  4. filtering of combo box / vba code
    By Kotoca in forum Programming
    Replies: 2
    Last Post: 02-08-2012, 08:15 AM
  5. Replies: 8
    Last Post: 03-14-2011, 09:45 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums