By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,654 Members | 1,599 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,654 IT Pros & Developers. It's quick & easy.

Requery Combobox after Updating List in Another Form

P: 6
I am using Microsoft Access 2007. I have a list in a dropdown combobox (Field_One) in a form (Form_One). Users have the option to click a button if the item they need does not appear in the combobox, and another form, (Form_Two) opens to which they can add the new item (in Field_Two). After adding the new item in F_Two I want the combobox in F_One to requery without having to close and reopen F_One. I think I can do this with an After_Update event, but to which object should the event apply? Or is there a better way to do it?

Thank you
Jul 28 '10 #1
Share this Question
Share on Google+
4 Replies


Expert 100+
P: 636
@Organizer
Hi

Maybe something like this in Form_Two
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_AfterUpdate()
  2.     If CurrentProject.AllForms("Form_One").IsLoaded Then Form_Form_One.ComboBoxName.Requery
  3. End Sub
??

MTB
Jul 29 '10 #2

missinglinq
Expert 2.5K+
P: 3,532
Users have the option to click a button if the item they need does not appear in the combobox, and another form, (Form_Two) opens to which they can add the new item (in Field_Two).
In the code behind your button, why not simply
  • Open Form_Two with the Window Mode argument set to Dialog
  • Follow the form opening line of code with Me.ComboName.Requery
Welcome to Bytes!

Linq ;0)>
Jul 29 '10 #3

P: 6
Thanks for he suggestions. Problem not solved yet.

MTB: I replaced the code I had with your new suggestion, but got the same result. Updates from Form_Two show, but new additions don't until I close and reopen Form_One.

Linq: I looked at the code behind that button. I'm afraid that your suggestion is a little beyond me, since the Window Mode argument isn't already there - I don't know how to write it. But, reading the suggestion, how would having the requery happen in conjunction with clicking that button help, since that button opens the form where the new item will be added, so at the time of clicking the new item doesn't exist so there is not yet anything new for the requery to find?

Is it a problem that this combobox was created at the table level, rather than at the form level (so it was automatically a combobox when I added the field to the form)? Or does that not matter?

Thanks again. Hope we can crack this.
Jul 29 '10 #4

Expert 100+
P: 636
@Organizer
Hi
Is it a problem that this combobox was created at the table level, rather than at the form level (so it was automatically a combobox when I added the field to the form)? Or does that not matter?
That shouldn't matter at all.

So, in Form_Two you are adding an additional record into the table that the combobox on Form_One is based. Is that correct?

If so how is the insert accomplished?

Is it a form bound to the table?

Have you check that the code in the Form_AfterUdate event is running correctly or at all?
For instance, you could put this line in the event

msgbox CurrentProject.AllForms("Form_One").IsLoaded

This should display True if correct, or False if not added correctly (ie the form name is wrong or its not loaded, or not be displayed at all if not firing!!

MTB



MTB
Jul 30 '10 #5

Post your reply

Sign in to post your reply or Sign up for a free account.