Combo box requery

C

Corinne

I have a form that has a combo box to look up the name of
the record I wish to find. If I add a new record to the
form the name does not appear in the combo box until I
close the form and re-open it. I am sure I have seen
somewhere that it is possible to do a requery to save
having to close the form. I have search for days and
unable find what I am looking for. I am quite new to this
and will need specific instructions as to where to put
the code in the properties if anyone does have an answer
for me.
Thanks in advance.
 
P

Phil Carrero

Corinne:
On the After Update property of the Form

Private Sub Form_AfterUpdate()
Me!MyComboBox.Requery
End Sub

Also, if you want it to not display any longer a record just deleted

Private Sub Form_Delete(Cancel As Integer)
Me!MyComboBox.Requery
End Sub

Phil

I have a form that has a combo box to look up the name of
the record I wish to find. If I add a new record to the
form the name does not appear in the combo box until I
close the form and re-open it. I am sure I have seen
somewhere that it is possible to do a requery to save
having to close the form. I have search for days and
unable find what I am looking for. I am quite new to this
and will need specific instructions as to where to put
the code in the properties if anyone does have an answer
for me.
Thanks in advance.
 
A

Al Camp

Corinne,
On the AfterUpdate event for your [CustName] (or whatever field you want
to initiate the Requery from), place this code...
Refresh
Me.cboMyCombo.Requery
The Refresh will update the record, and the Requery will add the name to
the combo box.
 
D

D

Since I often send users to related forms to add new data, I prefer to
requery when the combo in question gets focus, which ensures the update when
the user returns to the combo's form.

For example,

Private Sub cboWhatever_GotFocus()
Me.cboWhatever.Requery
End Sub

Don't forget your error handling!

D
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top