How to Update Combo Box Query from Form

B

Brian Reed

I have an access form that I am coding in my Access XP database. One of the
controls on the form is a list box that uses a query to fill its data set.
The problem that I am having is in trying to update the query while the form
is open. The form is used to add users and when I add a user via the form I
want to the control to rerun the query without closing and opening the form
again. Is there anyway to do this?

thanks,

brian
 
S

SFAxess

What I usually do is just add code like this to the On
Enter event of the combo box

me.NameOfComboBox.Requery

If you haven't done much VBA programming with forms, let
me know and I will explain what I mean.
 
G

Graham Mandeno

Hi Brian

You just need to requery the list box when the list is likely to have
changed. In your case this will be after a record has been added, so you
should use the AfterInsert event procedure:
Me![My Listbox name].Requery

You might find you need to do it after records are deleted too, and also
after the name has been changed and the record saved.
 

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

Top