Refresh Combo Box

brharrii

Registered User.
Local time
Today, 00:39
Joined
May 15, 2012
Messages
272
I have a combo box based off of a query of a table that I'm trying to tell to requery the list it provides each time it's opened. The user may need to add new records to the table sporatically (through a pop up form I've created) so I need for them to be able to have live data each time they click the drop down of the combobox. I have the following code on the "on got focus" property of the combobox but It only seems to work after I've add a new record directly into the table. If I attemt to add a record through a form that pops up, then the list doesn't update.

Any ideas?

Thanks!

Code:
Private Sub cboPlantManager_GotFocus()
    DoCmd.Requery "cboPlantManager"
End Sub
 
Are you sure the data entered in the popup form, is going into the table from where the combo box gets it data, (have you checked?)?
 
Yeah, the data is going to the right table.... It's strange though:

When I enter the data into the popup form I then close the form with a button to go back and check to see if the record is showing up in the combobox on my main form. If the table in question is open I notice that no record immediately shows up on the table, that is until I close the table and re-open it. If I check the combo box before closing and re-opening the table then the new record is missing from the combobox list. If I check the combobox after closing and re-opening the table then the vba code seems to be able to refresh the combobox with the new record.

If I start with the table closed and enter a record through the pop up form. The record doesn't show up in the combo box. If I then open the table and see the new record there, I can then go back and click on the combobox and the VBA code successfully updates the record list..... strange.

The only other odity I can think to mention is that the query behind the comobox has a where statement that checks for a true value in a yes/no datatype field.

Really stumped on this one.....
 
..
If the table in question is open I notice that no record immediately shows up on the table, that is until I close the table and re-open it.
It is the normal behavior in MS-Access.
..
If I start with the table closed and enter a record through the pop up form.
You need to save the data in the form, if you not close the form.

If you have a stripped version of the database with some sample data, then post it.
 
The problem is that the combo box never lose the focus when the popup form opens/closes.
If you add the below code on the popup form's on close event, then the combobox is updated.

Code:
Private Sub Form_Close()
  Forms!frmPlants!cboPlantManager.Requery
  Forms!frmPlants!cboQCManager.Requery
End Sub
 

Users who are viewing this thread

Back
Top Bottom