Requery Combobox after Updating List in Another Form

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Organizer
    New Member
    • Jul 2010
    • 6

    Requery Combobox after Updating List in Another Form

    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
  • MikeTheBike
    Recognized Expert Contributor
    • Jun 2007
    • 640

    #2
    Originally posted by Organizer
    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
    Hi

    Maybe something like this in Form_Two
    Code:
    Private Sub Form_AfterUpdate()
        If CurrentProject.AllForms("Form_One").IsLoaded Then Form_Form_One.ComboBoxName.Requery
    End Sub
    ??

    MTB

    Comment

    • missinglinq
      Recognized Expert Specialist
      • Nov 2006
      • 3533

      #3
      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.Re query

      Welcome to Bytes!

      Linq ;0)>

      Comment

      • Organizer
        New Member
        • Jul 2010
        • 6

        #4
        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.

        Comment

        • MikeTheBike
          Recognized Expert Contributor
          • Jun 2007
          • 640

          #5
          Originally posted by Organizer
          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.
          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

          Comment

          Working...