How to Get a Combo Box to Refresh

whdyck

Registered User.
Local time
Today, 14:37
Joined
Aug 8, 2011
Messages
169
I'm using Access 2003.

I'm trying to make a combo box refresh in a given form after making changes to the cb from another form (while the original is open).

So here's the sequence:
1. User opens main form containing cb control.
2. User adds or changes an entry in the table feeding the cb (from within another edit form)
3. User clicks on cb on main form and wants to see the revised list.

Unfortunately, I cannot get it to work. I tried adding a Requery command to the OnClick event of the cb to no avail:

Code:
Private Sub cmbVesselID_Click()
    Me.cmbVesselID.Requery
End Sub

I realize that I could have the combo box add the new entry on the fly, but the clients do not want that.

Is this possible?

Thanks for any help you can give.

Wayne
 
The other form would need to requery the original form's combo. Usually on the close event of that edit form or if it remains open it would be in the After Update event.

Code:
If CurrentProject.AllForms("MainFormNameHere").IsLoaded Then
   Forms!MainFormNameHere.cmbVesselID.Requery
End If
 
The other form would need to requery the original form's combo. Usually on the close event of that edit form or if it remains open it would be in the After Update event.

Code:
If CurrentProject.AllForms("MainFormNameHere").IsLoaded Then
   Forms!MainFormNameHere.cmbVesselID.Requery
End If

Hi, Bob,

I must be doing something wrong, because when I add your code to the After Update event, I get the following error:
You must save the current field before you run the Requery action.
I tried this code in the After Update for the field, then the record. Same error both times.

Thanks.

Wayne
 
what i normally do is this

from the main form

- open popup form
- amend items that would be in the combo box
- wait for popup form to close
- then do combobox.requery

but your problem may be trying to requery the combo box, which it is the current field (not sure without trying though)
 
2. User adds or changes an entry in the table feeding the cb (from within another edit form)
<---------------------------------------------->
3. User clicks on cb on main form and wants to see the revised list.
What happens in between these two steps? Is the form in step 2 bound? How are changes saved?
 

Users who are viewing this thread

Back
Top Bottom